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

Free Support Forum - aspose.com

Preserve TOC Page Numbering, Coloring and Table Layout during DOCX to HTML to DOCX Conversions using C# .NET

Hi Team,
Setps:
1.Converting word document to HTML using aspose word
2. Converting (Converted HTML doc) to word using Aspose word

Issues:

1.Table of content text color display as blue color when converting html to word using aspose word (Refer screen shot :TOC Issue_Converted doc.png (106.4 KB) )
2. Table of content Page number not displayed in Converted document (Refer screen shot :TOC Issue_Converted doc.png (106.4 KB) )
3.Table alignment issue (Refer screen shot : Table alignment.png (113.1 KB) )

below sample code for we are using :
Aspose.Words.License license1 = new Aspose.Words.License();
license1.SetLicense(“Aspose.Total.lic”);

//Convert word to html
Aspose.Words.Document doc1 = new Aspose.Words.Document(@“D:\FileTest\ManiDocument.docx”);
Aspose.Words.Saving.HtmlSaveOptions options = new Aspose.Words.Saving.HtmlSaveOptions(Aspose.Words.SaveFormat.Html);
options.ExportImagesAsBase64 = true;
doc1.Save(@“D:\FileTest\ManiDocument.html”, options);

//Convert html to word
Aspose.Words.Document doc2 = new Aspose.Words.Document(@“D:\FileTest\ManiDocument.html”);
doc2.Save(@“D:\FileTest\ConverteddocHTMLTOWord.docx”, Aspose.Words.SaveFormat.Docx);

Please find the attachments for your reference:
Original Document screenshots: Original Document.png (105.4 KB)
Sample document : Sample Document.zip (83.7 KB)

@thiru1711,

We tested the above scenarios and have managed to reproduce the same problems on our end. For the sake of corrections, we have logged the following issues in our issue tracking system.

WORDSNET-19866: TOC color changes to blue when converting Word to HTML
WORDSNET-19867: Preserve TOC Page numbers during Word to HTML to Word round-trip
WORDSNET-19868: Tables width increase beyond the Page width during Word to HTML to Word round-trip

We will further look into the details of these issues and will keep you updated on the status of corrections. We apologize for your inconvenience.

Regarding problem 2, Aspose.Words does not export TOC page numbers in HTML, because TOC page numbers do not have any value/logic in HTML format. MS Words also does not export TOC page numbers in HTML. Moreover, there is no numbering in TOC after round tripping back to Word format. Currently, Aspose.Words does not write PAGEREF fields to HTML, so page numbers are not preserved. Probably, we can fix this as per WORDSNET-19867.