Open adiRandom opened 3 months ago
I have a same issue. Any update?
Same thing here :(
This problem makes me waste a lot of time, because I was wondering the problem was my fault. Given your opened issue @adiRandom, I tried open in Google docs, worked fine. But I'm using patchDocument().
EDIT - I seemed to have resolved my issue by changing the PatchType to DOCUMENT
, this is likely a misunderstanding on my part, but hopefully it may help someone else in the future:
I was experiencing the same issue.
Originally, I had been using this library to "patch" my master file, then convert the buffer data into a PDF using Libreoffice (command line), this worked fine for me, no issues. My client asked to just receive the docx file so they could make minor updates to the generated file - but for some reason, MS Word would throw the "Word experienced an error trying to open the file. Try these suggestions...
" error every time. I dug into the internals a bit to try to figure out what was going on.
What I found, using an OOXML validation tool, was that my generated file was inserting the dynamic table as a child of a paragraph <w:p>
, which is apparently not allowed according to the schema if I am reading the documentation correctly. It seems other applications are more forgiving, but MS Word just flat out refuses to open the document.
Here is an image of the document.xml
snippet prior to using the patcher:
Here is an image of the document.xml
snippet after using the patcher:
(note: I've collapsed the table code so you can see the open and close paragraph tags)
To open the patched document in MS Word again, I simply had to remove the parent <w:p>
tags. Unfortunately, removing the parent <w:p>
tags in the master template file (just leaving the {{PAYTABLE}}
) does not work. The docx file is patched, but the tables do not get generated.
I am trying to generate a document from a template using
docx
. After I run my code, if I open the resulting document using Google Docs it works just fine. But neither MS Office nor Apple Pages manage to open the file. And unfortunately, I need the files to open in Ms Office.Here is the code I am using to generate the files, which I assume is correct since Google Docs can open the document:
I also attached a document produced by my code.
15.docx