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

Free Support Forum - aspose.com

Insert html into word and convert to pdf


We are trying out Aspose words for our requirement over here and we could not exactly get the solution for us using Aspose words. Let us know if we are following the correct path or are we missing anything here.

We have a requirement of converting an edited docx file into pdf. The docx file has bookmarks which we were able to fill in with data using Aspose. However we have a typical scenario where in we have header which is different for the first page. So we have set up a header (with image) which is different on the first page and the subsequent pages have a different header. We also have bookmarks for fitting in variou data elements. We also have this requirement of inserting html data into this word document. We used AppendDocument for inserting the html but since we have 2 different bookmarks it is always appending to the second page and keeping the first page empty. Also some formatting are also lost (even basic formatting like underlines). We also tried using mail merge which does not work for some reasons and also the inserthtml method which does not keep the formatting at all. I have attached the html that we are trying to put it in word, the word document itself and also some code parts. Let us know if we can achieve our requirements with Aspose.



Thanks for your inquiry.

First of all please note that AppendDocument method always appends the specified document to the end of another document:

Secondly, to be able to insert a document in a bookmarked place, I think you can achieve this after reading the article suggested below:

Please let me know if I can be of any further assistance

Best Regards,

Hi Hafeez,

Thanks for the reply. We tried using the InsertDocument function and it worked perfectly fine for our scenario. However we are not able to get all the formatting information in the html to the word or pdf document. Is there a way we can persist all the formatting information across the word and pdf documents. I also tried to put the html into a word document using OpenXml and then insert the word document but met with little success.

To summarize I want to insert the content of any of the attached files into the word and then convert it to pdf with the formatting (like underlines and bold) persisted.



Thanks for the additional information.

The problem occurs because currently Aspose.Words does not support inheriting styles from parent objects in HTML. Please see the following document to learn more about restrictions during HTML import/export:

Moreover, Aspose.Words expects that font formatting is set in , , or element, formatting of paragraph is set in


elements etc. Your request has been linked to the appropriate issue and you will be notified as soon as this New Feature is available.

Sorry for inconvenience.

Best Regards,

The issues you have found earlier (filed as WORDSNET-2021) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.