Hi Eric,
our app (Electron.js) generates HTML and our users import it manually into their Word documents. We want to automatize the process. A user prepares a template docx with some mark and we insert the HTML into the DOCX where the mark is.
Our current idea is let the user put into her template the MERGEFIELD
, e.g. MERGEFIELD ReplaceHere
field and replace it with the altChunk
element. We would like to use a pure JavaScript solution if possible, i.e. some JS XML parser or maybe your outdated openxmlsdkjs. So far, I have hit two problems:
- The
MERGEFILD
text is not always easy to find, because it may be split into multiple w:instrText
elements.
- The
altChunk
has to be a sibling to <w:p>
element so we may place it in a wrong place. Probable solution is to find nearest <w:p>
parent and replace it?
- If the HTML contains some bigger image, then it’s not shown. Word shows the layout of inserted HTML overlaps with the original docs content.
Do you think is inserting HTML doable this way? Do you know some better way how to make some user-made markup in DOCX and insert/import HTML there?
Thanks
Andy