Inserting HTML formatted text into a Word document

Hi,


I’m trying to update a word document in aspose cloud storage using bookmarks (wordsService.WordsBookmarks.UpdateDocumentBookmark). Simple updates work fine and I get the expected result. Now, however, I’m trying to insert some HTML from a rich text editor (Telerik Kendo UI Editor) into the document without success.


I found out about a method DocumentBuilder.InsertHtml in the Aspose Words Component, but can’t seem to find anything relevant from the Cloud version. Is there a way to complete such insertion through the cloud API and if so, how?

Hi Tuukka,

One way to insert HTML text is to use exectuteMailMerge API as you can see in this example. There are following limitations in this case.

  • HTML fragment in XML must be encoded. e.g. in XML must be like

  • Setting styles through “style” attribute of element will not work e.g., if you use the HTML fragment

Text

, you will get document without any styles

  • The only way now to set styles is using inline CSS e.g. if you use the following fragment .cr

Text

, you will get document with styles as in browser

Please check attached template and XML for reference.

Best Regards,