Page 1 of 1

HTML tags in generated docx

PostPosted: Fri Jul 28, 2023 5:47 pm
by Michael
I would like to ask if it is possible to enter HTML tags in the generated text when generating a docx document, e.g. string "Sample text with <b>bold</b> tag".
I would like the word "bold" to be bold after generating the document. Currently, in my docx4j program, it simply writes tags to the document without recognizing them as HTML tags.

Re: HTML tags in generated docx

PostPosted: Mon Jul 31, 2023 9:16 pm
by jason
It depends what approach you are using for document generation.

OpenDoPE content control data binding will convert XHTML input (where the sdt tag so directs); it does this using docx4j-ImportXHTML.

Other approaches to document generation may not do this. For example, docx4j's variable replacement doesn't do it.

Re: HTML tags in generated docx

PostPosted: Mon Jul 31, 2023 9:43 pm
by Michael
I'm using docx4j's variable replacement.
I think docx4j-ImportXHTML will be the best solution.
I am a docx beginner and I thought that docx4j-ImportXHTML is for generating a document from HTML code and cannot be used to save a regular String with HTML tags.