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

Free Support Forum - aspose.com

Table of Contents- Figures- Tables

Hi All,

I am using Aspose Words 13.2.0 to generate and add table of contents (TOC), figures (TOF) and tables (TOT) while converting MS Word documents to PDF. I have a few queries regarding this :

1. How do I check whether the MS Word document I have already contains TOC/ TOF / TOT? I need to check if these are present and add them only when they are absent. I do not want the document to end up with 2 TOCs. Can you please guide me to the appropriate API to achieve this?

2. While adding TOT/ TOC/ TOF, how do I recognize that these are not empty? For example, while adding TOC to a word document that has only 10 lines of plain text, I get a “No table of contents entries found.” message. I want to check if there are TOC entries before trying to add it and avoid the above message.


Hi Smitha,

Thanks for your inquiry.

Please note that TOC, TOF and TOT are all represented by fields in Microsoft Word document. You can detect the presence of anyone of these fields by looping through all FieldStart nodes in your document and comparing FieldStart.FieldType with FieldType.FieldTOC. Once found, you can then look further into field codes (see getFieldCode method here) to detect if it’s TOF or TOT.

Secondly, you need to first call Document.UpdateFields to update TOC, TOF or TOT fields and then look for the ‘No table of contents entries found.’ string in the field result which is a Run node between field separator and field end nodes.

I hope, this helps.

Best regards,