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

Question

Question

Add Image to Word Document

asked on May 1, 2018

Hi,

Is it possible to merge images from the repository into a Word Document via workflow using the Update Word Document Action?

0 0

Replies

replied on May 2, 2018 Show version history

Hello mike,

 

i was able to do that in the following way but first you need to make sure that the document has an image :

i made a SDKSript in the workflow to export the document into a location on the server and convert it to base64 string as follows :

 Protected Overrides Sub Execute()
            'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            dim doc as DocumentInfo = me.BoundEntryInfo
            Dim exporter As New DocumentExporter()
                    ' configure the exporter to export images as JPEG, include annotations, and burn-in redactions.

            dim pages as PageSet = doc.AllPages
                    ' export the first page of the document to C:\ on the local system
                    exporter.ExportPages(doc, pages, "C:\DocumentExportSample.jpg")

            
            SetActivityTokenValue("Token","data:image/png;base64,"+Convert.ToBase64String(File.ReadAllBytes("C:\DocumentExportSample.jpg")))

        End Sub

then i configured the field in the word document like this:

«Image:image» 

and in the workflow you use the update word document activity to put the activity token created in the word document.

you need to handle the size of the image which i did not do, also note something that you can delete the exported file, and one more important thing, the workflow token have size limitations so if the document was too large you will not succeed in converting it to base64String and using the token.

 

hope this was useful.

Maher.

 

 

3 0
replied on May 24, 2019

This works great for single images.  I am trying to do this but with multiple images in a table.  Please take a look at my post if you have some time. Thanks

0 0
replied on October 4, 2021

Could you show your Workflow configuration?

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

Sign in to reply to this post.