Convert DOCX with TOC to HTML

Hi,

I have a docx document which includes a table of content. When I convert it to HTML, the TOC looks different from original Word document. The numbers aren’t aligned to right. Do you have any ideas with this issue? I attach docx and html in this post.

This is my code.

LoadOptions loadOptions = new LoadOptions();
loadOptions.LoadFormat = LoadFormat.Docx;
Document doc = new Document(fullFilePath, loadOptions);

HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
htmlSaveOptions.PrettyFormat = true;
htmlSaveOptions.SaveFormat = SaveFormat.Html;
htmlSaveOptions.AllowNegativeLeftIndent = true;
htmlSaveOptions.ImagesFolder = Utils.CreateDirectory(fullFilePath);
htmlSaveOptions.ImagesFolderAlias = Utils.GetShortFileName(fullFilePath);
htmlSaveOptions.ExportDocumentProperties = true;
htmlSaveOptions.ExportXhtmlTransitional = true;
htmlSaveOptions.ExportHeadersFootersMode = ExportHeadersFootersMode.FirstSectionHeaderLastSectionFooter;

this.Save(doc, htmlSaveOptions, sOutputFile);

Thanks.

Any ideas could help to figure out this issue?

Hi Truong,

Thanks for your query. I have tested the scenario with latest version of Aspose.Words for .NET and have found another issue. The page numbers of table of contents are missing in output HTML. I have logged this issue as WORDSNET-6894 in our issue tracking system. I have also logged the same issue which you are facing in our issue tracking system. (The numbers aren’t aligned to right).

I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Hi Truong,

Further to my last reply, Please use HtmlSaveOptions.ExportTocPageNumbers propery to export TOC page numbers in output HTML. I have logged the page number alignment issue as WORDSNET-6907 in our issue tracking system. I have linked this forum thread to the same
issue and you will be notified via this forum thread once this issue is
resolved.

Document doc = new Document(MyDir + "in.docx");
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.ExportTocPageNumbers = true;
doc.Save(MyDir + "AsposeOut.html", saveOptions);

We apologize for your inconvenience.

Hi Truong,

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Hi,

We are facing the same issues as WORDSNET-6907 and would like to ask for the status of this issue.

When converting a ToC from Word to HTML (by using the Word function) the ToC is exported to HTML with the “…”, e.g.

Heading 1…3
Heading 2…5

We would assume that this behavior would also be applicable with Aspose.Words by setting the “ExportTocPageNumbers” property to true or maybe adding another property for controlling the dot addition.

Thank you.

Hi Hristo,

Thanks for your inquiry. I am afraid this issue WORDSNET-6907 has now been postponed till a later date due to some other important issues and new features. We will inform you as soon as there are any further developments.

Unfortunately, Aspose.Words does not support tab leaders (e.g dots) upon exporting to HTML at the moment. However, we had already logged this feature request as WORDSNET-5003 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

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


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

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


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