Free Support Forum - aspose.com

Mhtml to Word Headers and Footers

Hi


I have a generic service that converts Word Docs to PDF. Some of thhe files I am converting are MHTML. When these files are converted they lose their headers and footers.

I noticed an old forum tickets that said this wasn’t supported, but that was back in 2009, so I’m wondering if it is supported now or if a fix could be put in to fix it?

I have attached an example file.

Thanks

Jared

Hi Jared,


Thanks for your inquiry. I would suggest you please first take a look at HtmlSaveOptions.ExportHeadersFootersModeproperty below:
http://www.aspose.com/docs/display/wordsnet/ExportHeadersFootersMode+Enumeration

It is hard to meaningfully output headers and footers to HTML/MHTML because HTML/MHTML is not paginated. When this property is ‘PerSection’, Aspose.Words exports only primary headers and footers at the beginning and the end of each section. When it is ‘FirstSectionHeaderLastSectionFooter’ only first primary header and the last primary footer (including linked to previous) are exported. You can disable export of headers and footers altogether by setting this property to ‘None’.

If we can help you with anything else, please feel free to ask.

Hi


I think you may have misunderstood requirement. I am converting from mhtml to pdf, not word to mhtml.

The document attached is in mhtml format (it has a .doc extension so it opens in word). You will see it has headers and footers when opened in word. When I try to export this file as a pdf (or word doc) using Aspose it loses it the header and footer.

Any help would be much appreciated.

Regards

Jared

Hi Jared,


Thanks for sharing the detail. Upon processing HTML, some features of HTML might be lost. You can find a list of limitations upon HTML exporting/importing here:
http://www.aspose.com/docs/display/wordsnet/Load+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format
http://www.aspose.com/docs/display/wordsnet/Save+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format

Your problem is related to Microsoft “mso” attributes. Currently special Microsoft “mso” attributes are not imported or exported with the exception of "mso-break-type"which is supported both in import and export. These properties help with round-tripping HTML back to a document format but significantly bloat the HTML which is why most users want to avoid such extra markup. However since it is a useful tool to provide Word-HTML round-trip, we will support these attributes both import and export in a future version.

We apologize for your inconvenience.