No table of contents entries found when converting .docx to .pdf

Hi Aspose Team,

We’re using your excellent tool to convert .docx files to .pdf files.
It works great, but recently we have added the UpdateFields() method, and we’ve found one and a particular issue in the document with TOC. Instead of updating the TOC, Aspose returns “No table of contents entries found.”

Screenshot 2021-11-10 at 16.47.52.png (67.9 KB)

Requirements:
1 - Document is generated in Windows’s MS Word.
2 - It happens only with “custom” TOC.

The smallest file which is broken:
broken custom toc.docx (32.2 KB)

Thank you!

Sincerely,
Vadim

@vadym.shashkov

Please note that list separator is comma (,) for English culture and it is semicolon (;) for Ukraine culture. Please check the language of TOC field code in your document.

You can use FieldOptions.CustomTocStyleSeparator property to set custom style separator as show below to get the desired output.

Document doc = new Document(MyDir + @"broken custom toc.docx");
doc.FieldOptions.CustomTocStyleSeparator = ";";
doc.UpdateFields();
doc.Save(MyDir + "21.11.pdf");

Thank you, it helped!

But is there any way to preserve CustomTocStyleSeparator on a document level?
I mean, I want to use , in a document, even if for Ukraine it’s ;?

@vadym.shashkov

Yes, you can change the ; with , in your Word document.

Please note that if you execute the following code example under Ukraine culture with list separator as comma, the output will be without TOC. You need to change the culture to English to get the correct output.

{ TOC \t “AXDSTYLE,1” * MERGEFORMAT }

string culture = "uk-UA";
Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
Document doc = new Document(MyDir + @"broken custom toc.docx");
doc.UpdateFields();
doc.Save(MyDir + "21.11.pdf");