Table of contents page numbers incorrect when exporting Word documents in Aspose Word Java

Dear Aspose support team,

I am experiencing an issue with the Aspose Word Java library when exporting Word documents in my application. When I run the application in my local Windows environment, everything works fine and the table of contents is exported with the correct page numbers. However, when I deploy the application to my CentOS dev environment, the exported Word documents have an incorrect table of contents.
localhost: toc : numbers : 3,5,11,15,16
dev env : 3,5,11,16,17

Here are some details about my environment and setup:

  • Java version: 1.8
  • Aspose Word Java version: 18.11
  • Operating system in local environment: Windows
  • Operating system in dev environment: CentOS

I have included the relevant Maven dependency information above.

I would appreciate your help in resolving this issue as soon as possible. Please let me know if you need any additional information or if there are any specific steps I can take to troubleshoot the issue.

Thank you for your assistance!

Best regards,

<java.version>1.8</java.version>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-words</artifactId>
    <version>18.11</version>
    <classifier>jdk16</classifier>
</dependency> 

local env : windows
dev env : CentOS

@BrollySlan The problem in dev environment might occur because the fonts used in the source document are not available in the environment where the document is processed. Upon building document layout, if Aspose.Words cannot find the fonts used in the document the fonts are substituted . This might lead into the layout difference, since substitution fonts might have different font metrics. In turn, this might lead to incorrect page numbers in the TOC. You can implement IWarningCallback to get a notification when font substitution is performed.
The following articles can be useful for you:
https://docs.aspose.com/words/java/specify-truetype-fonts-location/
https://docs.aspose.com/words/java/install-truetype-fonts-on-linux/