Preserve HTML formatting in word

Hi I am not sure if this is a Aspose question or a Word question. I have a field that is storing HTML formatting in our DB. Nothing fancy, things like bold, underline paragraphs,etc…


We then merge this field in to a word document. The merging is working great but word is not interpreting the formatting in the field. It sees it as plain text.

For example instead of showing this as bold
it is showing it as bold

Thanks for any help!

Hi Cameron,

Thanks for your inquiry.

Please try using the DocumentBuilder.InsertHtml method to insert your content into the document with. http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.documentbuilder.inserthtml.html

If you have any further problems, could you please attach your code here for testing?

Thanks,

Thanks Adam I will give that a shot and post the results.

Adam, I followed the code as the article suggested. My callback method is getting called but my field isnt being populated. Then I noticed the difference, the article has the fields being populated after a straight merge. My field is contained inside of a table(aspose table not a word table) This is causing some weird behavior to show up. If my field name in my table does not match the field name in the document i.e. word has hmtlField1 but my table has a record with a field in it called just Field1. I see the callback get called successfully for the field but the value is blank. If both field names match i.e. word has htmlField1 and my table has a record with a field called htmlField1then I do not see it show up in the callback but when the document is rendered the values are populated just not formatted correctly.


Thanks for any help you can provide.

Hi Cameron,

Thanks for this additional information.

Could you please attach your template and code here for testing?

Thanks,

The code worked as expected and was really easy to implement. I was doing multiple merges and I was applying the call back class in a different spot.