Images in DOCX Template

Is it possible to add images to the final DOCX file? I’m thinking specifically photos from the camera in PowerApps or a pen input for signatures.

I can get the base64 from the pen input or camera control in Powerapps and add it to the DOCX dynamically but at the moment it adds it as a text string, is there any functionality to render it as an image?

I have thought about going down the HTML template route instead as I’ve seen examples there but wanted to see if it was possible in DOCX first.

Thanks!

Hello @danhfc, thank you for your message.

Unfortunately, Create DOCX from a template action doesn’t support images yet.
However, we are planning to add support both base64 and link to picture formats in future.
For now, you use this action to create HTML documents, it supports images.

I noticed the updated DOCX actions are available including new table functionality, are images supported yet?

The invoice demo contains a signature, does this mean it’s possible now or is this a static image?

I may have found a rather convoluted workaround to getting a signature from PowerApps to an HTML template using Flow, OneDrive and FTP but if the DOCX action could support images natively it would make the whole process brilliantly simple.

Hello @danhfc,

New actions were added to the public connector, but I’m afraid images aren’t supported yet.
The image in the invoice demo is static.

Hi @Oleg_Tsurkan I need to pass Base64 string which is a signature, can you kindly let me know if we have a solution yet? in word template or do we have any date when it will be available?

Thanks

Hello @Abbas_Khan,

We released a new action - Create DOCX document from template which supports images.

You can insert an image using a link to it or a base64 code. Please make sure that you added a proper variable to your DOCX template, it should look like this: {{yourImageVariable}:image}

Then, in the action, you should specify the image like that (in case of using base64 code):

{
“yourImageVariable”: “R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=”
}

Thanks @Oleg_Tsurkan I will try this.
I have noticed that for the last one hour, Create DOCX document from Template in Logic App have started producing completely blank word document, not sure whats wrong.

Hi @Oleg_Tsurkan
any idea why image isnt working? I have a very basic template with only one attribute in it as below

Hello test, simple template
{{yourImageVariable}:image}

I am passing JSON as below

However final converted word doc is not rendering image and is rather display base64 string.

Hello @Abbas_Khan,

The problem might be in the base64 code. Could you please make sure that it is working, you can use this service to do that.

Hi @Oleg_Tsurkan
It works on image converter however in Plumsail call it does not. Can you kindly have a look at the attached sample?test image plumsail.txt (6.0 KB)

Hello @Abbas_Khan,

We are sorry for the inconvenience, please try to use a new tag: {{yourImageVariable}:picture}

Hi, the image embedding works fine for me however the images are quite large and overflowing the areas I want to display them in my document. Is it possible to define the size of the image ? and constrain the proportions ?

Thanks

Hi, @Raphilass.

You can constrain the size of the image by creating the table and inserting it into a cell. So the cell size will predefine the size of the image.

Best regards, Kirill Shaklein

1 Like

Hi @kirill_sh,
I am doing this, but the image is bleeding out of the cell that I have added the tag in the screen shot attached I have a single cell table - about half a page width with the tag referenced as {{signatureImage}:picture}.

Running the flow and merging the Base64 String with the template gives an image which is nearly the full page width regardless of the width of the table cell it is contained in.

Any ideas ? Thanks

Hi, @Raphilass.

Please go to table properties and turn off ‘automatic resizing’ option:
image

Best regards, Kirill Shaklein.

Hi @kirill_sh,

I had tried that, in fact I tried changing a few settings on the table, column, row and cell. I have attached the resultant file, with the resize option disable and the width of the cell fixed (Top Example) and it simply hides most of the image rather than resizing the image.

I appreciate your help, any further ideas would also be appreciated.

Thanks
Phil

TestImageMerge.docx (58.5 KB)

Hi, @Raphilass.

Yes, preserving the sizes of the table you can’t simply change the size of an image, the simplest option here is to adjust it after pasting.

Best regards, Kirill Shaklein.

Hi @kirill_sh

Thanks,

so there is no way to do this automatically from data generated in a Microsoft flow ? the image would need to be resized manually after the document is generated ?

Thanks
Phil

Hi, Is that image from the peninput control? how did you send it over to the document?

Hi @Petr, is there meanwhile an option to insert pictures in a DOCX document with defined dimensions? I've seen that there is a picture value formatter (https://plumsail.com/docs/documents/v1.x/document-generation/common-docx-xlsx/formatters.html?highlight=picture#picture), but unfortunately I can only give the picture a fixed height and width without a dynamic aspect ratio. Do you have any idea for this requirement?