After developing a TypeScript script that transforms a JSON string into a Word Doc poster using Docx, I encountered a hurdle. Certain sections of the JSON may contain HTML tags, such as
<br/>, <i>, <p>
, and I need a way to pass the string in and return specific DocX objects like a Paragraph
or a TextRun
.
While I came across the Html-to-Docx package, it seems to require a complete HTML string to generate a file, limiting my control over the content displayed in the Word Doc. I'm hesitant to switch to another library like OpenXML and am wondering if there is a feature within DocX itself that can help me achieve this. Alternatively, should I manually parse the strings to identify and convert the
<br/>, <i>, <p>
tags into DocX objects?
Any insights or suggestions on how to best approach this challenge would be greatly appreciated. Thank you.