We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replace Tokens in Word Template DOCX Document with Text & HTML Values from Database Java | Normal Font Style

Hi,
We have a template feature where we replace some tokens with values from the database in our application. Some values are plain strings and some are HTML. We pick the format of the token and apply it to the values while replacing tokens. While the plain string values are replaced properly and take the font type and size applied from the token format, the same is not working when we apply to the HTML being inserted as new word document. The new doc snippet containing the HTML and replacing the token is picking the Normal style identifier defined in the word doc even after I set the font type and size explicitly. We need help in replacing this new doc containing the HTML appropriately inserted with the custom format.

We changed the way we insert the HTML in the document based on your suggestion in the following post: Remove Extra Line Break while Inserting HTML in Word Document after a Hidden Character using Java Code

Please find the sample, code, input and output attached for your reference.TokenstyleIssue (4).zip (83.4 KB)

Thanks

@Gptnrt,

You have provided two documents in “resource” folder - “output.docx” and “expected_output.docx”. These two documents look identical. Can you please also attach here a comparison screenshot which highlights the problematic areas in “output.docx” that you want to fix? Please also share any other details/steps that you think might be helpful for us in understanding the scenario.