N8n Community node for DocX template -> Report

Hi there,

Some time ago, I developed a node for a client to be able to fill in DocX templates with data from a JSON object. The client allowed me to make it public, and now I finally had some time to do so.
You are also able to convert the DocX file to PDF, but you need LibreOffice installed on the server for this to work.

image

Have fun!

Developed for Energy SOAR - Security orchestration, automation and response tool.

8 Likes

Hey Bram, nice work. This works really well. Is there any support for dynamic images to be inserted into the docx template?

Cheers!
David

1 Like

It seems like the image plugin for the easy-template-x is not included in the npm package, so i suppose there is no support (as of yet)… I’m looking for this function as well so i’ll let you know if i find anything.

The node works as is. Not sure what you are talking about.
Just install and make sure to restart your n8n instance after installing.

1 Like

Sorry for the misunderstanding, it does work as-is! Thank you very much by the way for providing this plugin, amazing work and much appreciated that it is opensourced.

However, like @Davidwatters, i am trying to get n8n to insert an image from n8n (binary) into a Docx document and it seems this is not supported. Or am I doing something wrong?

Thank you very much for the node. I tried and it worked very well. However, when I download the file and try to open with word I always get an error saying that the file is wrong.
I can open it with google docs and also with Pages, but not with Word. It is funny that a doc file can be opened by other software rather than the one it was made for.
Do you know what can be the problem?

Have you added .docx to the filename?

I didn’t put .docx in the file because it says that i shouldn’t add the extension. This is a picture of the node. I download the template from minio (S3 bucket) and pass through the node, but when I download and open the docx… it is “corrupted”.

Hi @jRuMoL
Ah yeah oops. Forgot about that (is because you can also convert to pdf)
I see your file is actually a dotx that comes into the node. So possibly something going wrong there. Cannot really help any further as you are not inserting docX which is what it is built for. (never even heard of dotx to be honest)

OK. That was the problem.

.dotx files are templates. As this is an automation node to fill in templates of documents, I though the input should be .dotx files. However, I converted the input file into .docx and worked perfectly.

I don’t know if there could someone like me who had the same problem. May be you can consider adding this information in the guidelines.

Again thank for you great work. And by the way, do you know if there is a possibility of adding images to the documents. I have seen that someone asked about that but there were no answer.

The info says to fill in the DocX template. :slight_smile:

The n8n team could integrate this node natively/officially, so that it can be used in the n8n cloud.

I think this functionality is important for the n8n platform.

1 Like

Hi BramKn.

I really like your plugin and want to use it’s full potential. Sadly it’s not complete… Unless were in error, but I do not believe we are after testing.

While it parses document.xml it does not seem to parse footer1.xml to footer20.xml or header1.xml to header20.xml (1-20 are not static just examples as it creates a new header and footer for each unique header section.) for the headers and footers in the DOCX. This is an issue as any of the items in the the files for header and footer are not changed out in processing.

To fix the code it should load and iterate through all .xml files in the root folder. For example if the DOCX were extracted to Folder1 it should grab the names of all files with xml extensions, not just document.xml. Maybe ignoring fontTable.xml, styles.xml, numbering.xml for the sake of processing speed, although in all truth it would not affect them negatively regardless.

We also have a way to update images in the file so they render to the pages if your interested.

Hi,

The node is using a package that actually does the modifications. So you will need to check with the creators of that package for this issue with the headers and footers.

1 Like

I would be inclined to agree with you, except the fork fill-docx from your code uses a more up to date version of easy-template-x and it fills the fields throughout the templates. By that logic I would be inclined to believe the version of easy-template-x your using is out of date. Do with it as you will, but as you made the original I though you want to know. Yours also has the ability to render the pdf which is really nice.

The node was created a while ago. :wink:
I have no reason to update it, so I won’t be spending the time to do that.