Comment on post: Insert HTML and rich text into a Word Document with Power Automate

Blog post: Insert HTML and rich text into a Word Document with Power Automate



Hi I want to pass the richtext from power apps to a word document through an instant flow. How I can configure? Thanks.

Hello,

To transfer the rich text from the power apps you need to

  1. Add a token into your DOCX template with the HTML formatter.

image

  1. There is incorrect usage of the Template file in Create DOCX document from template action on the screenshot.
  • Pass the dynamic content from Power Apps in a JSON in the Template data field. The same as it's done for SharePoint.

image

or with Power apps dynamic content.

After running the action the token inside the DOCX template will be replaced with the power apps rich text content.

Best regards,
Petr
Plumsail team

Hello. I am passing an HTML table and the end result is the data without all the formatting.

This is the HTML I am passing:

table { width: 100%; border-collapse: collapse; } th, td { border: 1px solid black; padding: 8px; text-align: left; } th { background-color: #f2f2f2; } .level-1 { background-color: #4b0082; /* Dark Purple */ color: black; font-weight: bold; } .level-2 { background-color: #9370db; /* Light Purple */ color: black; text-decoration: underline; }
C1 C2 C3 C4 C5 C6 C7 C8 C9

This HTML is working properly if I send it over e-mail for example.

adding a screenshot as the HTML didn't display properly in the comment:

Hi @Pavel_Benev,

Do you use the HTML formatter inside a DOCX template like this and Power Automate action Create DOCX from template?

Could you share the DOCX template, and a screeshot with the action where you insert the HTML code? Is it possible to attach a txt file with your HTML code too?

Best regards,
Petr
Plumsail team

.

Hi @Petr and thank you for writing back.
Yes, this is my exact scenario. I have a word template
Document.docx (18.2 KB)
and I think I am following the instructions for using the HTML formatter inside the file.
I generate my HTML inside power automate and it looks like this:
HTML.txt (1.9 KB)
There is a variable RowsPlaceholder that I am providing later but I don't think it is important for this purpose because even the header's styling is not working.
At the end, this is how PA looks like:
image
Again I want to mention my disclaimer - the table is inserted in the word document but without any formatting at all. This HTML is rendering as expected when sent over an e-mail for example.

Waiting for your feedback :slight_smile:

Thanks and regards,
Pavel

1 Like

Hi @Pavel_Benev,

The <style> tag is not supported in the formatter. Please check the list of supported tags in the documentation.

Best regards,
Petr
Plumsail team

Hi @Petr , Thank you very much for your guidance! I've changed my HTML to no use the tag but to use inline formatting instead. Everything seems to be working as expected, except that in each line there is a space above and below the paragraph. Attached is my new code:
HTML.txt (2.6 KB)
Here is how the output looks like in word:


and this is how I actually want the table to look like:

Can you advise how to overcome this?

P.S. I tried without hardcoding the height of the row as well - same result.

Hi @Pavel_Benev,

We researched the issue and it's turned out that the html formatter does not handle the line-height correctly. We'll research it further and probably improve the html formatter to better handle all the options.

Best regards,
Petr
Plumsail team

Hi @Petr , and thank you so much for looking into this. In you experience, how likely is for Plumsail's dev team to introduce a fix for this (and what is the usual time line for introducing such a fix)? It is important for me to understand should I continue with Plumsail or I should consider another approach as this HTML is important for me and the goal that I want to achieve.

Hi @Pavel_Benev,

There is no due date for fixing the issue and it could take some time.

Could you probably try using Create HTML from template and Convert the result HTML to PDF?

Best regards,
Petr
Plumsail team

Hi @Petr ,

That is very unfortunate :frowning: I can't really do that because the HTML table should be just a piece in one, very big document, so I can't re-create the whole thing.