Incorrect Table of Contents page numbers even after setting setUpdateFields

I am facing an issue with GroupDocs where setUpdateFields is expected to update the Table of Contents (TOC) correctly in both DOCX and PDF outputs. However, the generated files contain discrepancies in some TOC page numbers.

While most headings display correct page numbers, a few entries are incorrect when compared to the actual document content.

I have attached the source document along with the generated DOCX and PDF files for reference and the code to generate these files.

Below are some examples of the mismatches observed:

  • Main Title: Introduction to Rich Text Content — Actual: Page 6, TOC: Page 7
  • Ordered List — Actual: Page 7, TOC: Page 8
  • Static Hyperlink — Actual: Page 8, TOC: Page 9
  • Standard Fonts — Actual: Page 21, TOC: Page 22

Can you please let us know if this is a bug and by when can this be fixed?

Steps to reproduce

  1. Copy the Groupdocs license under license folder with name as GroupDocs.Total.Java.lic
  2. Run below commands
    i. mvn clean install
    ii. docker build --platform linux/amd64 -t groupdocs-tocissue .
    iii. docker run -m 9g --cpus=2 -p 8081:8080 groupdocs-tocissue
  3. Run below commands to copy fonts used and generate docx and pdf files
    i. curl --location --request POST 'http://localhost:8081/api/conversion/copy-fonts?orgId=Org1'
    ii. curl --location --request POST 'http://localhost:8081/api/conversion/toc?orgId=Org1&fileName=TocIssue'

In the docker container under files you can see two files generated with names TocIssue_updatedToc.docx and TocIssue_updatedToc.pdf. Please check the Toc in those files

TocIssue.docx (775.5 KB)

TocIssue_updatedToc.docx (735.6 KB)

TocIssue_updatedToc.pdf (985.1 KB)

TocIssue.zip (3.0 MB)

cc: @pankajgupta @amitdash

Hello @ravi1994 ,

Thank you for contacting us. We have logged your issue in our tracking system under the ID CONVERSIONJAVA-3114. As soon as our development team investigates it, we will share their feedback with you.