You are viewing limited content. For full access, please sign in.

Question

Question

How to reflect the value of radio button of Forms to Word

asked on January 22

Hi Everyone

How can I configure a Laserfiche Form so that when a user selects a radio button, the selected value triggers the insertion of a corresponding image into a Word document via Laserfiche Workflow? Specifically, I need the Word document to automatically update based on the radio button choice, showing the appropriate image associated with the selection. What steps should I follow to ensure the radio button value is mapped correctly to the image in the workflow, and how can I ensure the image is inserted at the correct location in the Word document?

This version clarifies that you're looking to map the radio button selection to an image dynamically in a Word file using Laserfiche Workflow. Would you like help with the step-by-step process to set this up?

0 0

Replies

replied on January 22

I know you can use Workflow to add an image into a Word documents - we do it with signatures gathered on a Form process to generate an actual PDF letter with the signature included.

Here's some instructions - written by a Laserfiche team member - regarding how to do that: https://answers.laserfiche.com/questions/115453/Use-signature-collected-in-Forms-in-Workflow#repliestomain

And another post with instructions from a VAR user: https://answers.laserfiche.com/questions/145685/How-to-merge-signature-to-Word#145874

You should be able to do something similar, using the routing options in Workflow to determine which image to include based on the selected radio button options on your form, and then including it with the Update Word Document activity in Workflow.

The tricky part to work through will likely be getting the image where you can work with it, if you are not pulling it from the built-in signature field in Forms like those examples are using.  I believe you need to have the images in a Base64 string.  If you are using the same images every time, it might be easiest to find an online tool that lets you convert the image to the Base64 string, and then just include the string as a token in your Workflow.  Or, if you are wanting to have the users upload the images as attachments on your form, you likely want to review this post that includes a script to convert an image to Base64: https://answers.laserfiche.com/questions/141495/Add-Image-to-Word-Document#141502 and this post that is talking about implementing that script to work on images uploaded to a form: https://answers.laserfiche.com/questions/159715/Add-Multiple-images-to-a-word-document-table#repliestomain

What it sounds like you want to do, should be very doable, but it likely going to require some larger setup and testing to get off the ground.

0 0
replied on January 25 Show version history

Hi Matthew,

Thank you for giving this answers from other user or var.

But my case is different. The image I want to imbed to word file is from my drive (Drive C:)

I follow / used the code from this post you shared: https://answers.laserfiche.com/questions/141495/Add-Image-to-Word-Document#141502
but no output or result.

for the code I used is this

namespace WorkflowActivity.Scripting.SDKScript
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using System.IO;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1
    {
        public void RetrieveImageFromCDrive()
        {
            try
            {
                string imagePath = @"C:\checkmarkicon.png"; // Specify the PNG image path

                if (File.Exists(imagePath))
                {
                    // Load the image as a byte array
                    byte[] imageBytes = File.ReadAllBytes(imagePath);

                    // Now you can work with the byte array, for example, storing it in a database
                    Console.WriteLine("PNG image successfully retrieved from C drive.");
                }
                else
                {
                    Console.WriteLine("The specified image file does not exist.");
                }
            }
            catch (Exception ex)
            {
                // Using concatenation instead of interpolation to avoid the '$' error
                Console.WriteLine("Error retrieving image: " + ex.Message);
            }
        }
    }
}

please review my code if this correct and how I can imbed the image to the update word file.

 

Regards.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.