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

Free Support Forum - aspose.com

Table of content and page numbers

I’m facing a problem with the table of content. I made a simple scenario (in the zip file).
I load a word template, I insert html, I call the updateField method. In the end, when the table of content is more than one page long, the page number is wrong.
What’s funny is, when I right clic + update fields with microsoft word (or libreOffice Writer) the page number is well setted…

In my zip, you will find the result.docx with the wrong TOC. (I haven’t added the Aspose licence file)

TOC.zip (161.6 KB)

@rodrigue.leopold Unfortunately I was unable to reproduce the issue you mentioned. Please, attach your output document “result.docx” here. We will check it and provide you more information.

Sorry. I forgot to put it in the zip file

result.docx (96.5 KB)

@rodrigue.leopold I open your “result.docx” document and get the TOC with correct page numbers. What version of MS Word are you using for viewing? Have you changed any security default settings?
Screen.png (216.2 KB)

6.5.1, 6.5.2 and 6.5.3 are on page 71, not 70 on my word… that’s funny.

I’ll find another exemple… I was testing on LibreOffice, but my clients have the same problem with word 365…
OK… This one I opened it with word 365. (I can send you the HTML that I injected to generate the word if you wish)
Test_Pagination_-_Lot_Lot_de_test.zip (38.1 KB)


I see an issue in MS Word 2019 with updating the TOC in the last “Test_Pagination_-_Lot_Lot_de_test.doc” you sent.

Yes, please, attach the input Html.

Here is the HTML… I’ve made some tests, and the result is not the same, depending on the machine. Do you think that it could be because of missing fonts ?
content.zip (19.5 KB)


Yes it is possible.
Please run your code from the first post but save document to XPS format not to DOC.

doc.save(pathToResult, SaveFormat.XPS);

Attach output XPS file here.
Please note that all these steps shall be performed on one machine on which the issue appears.

Please note that all these steps shall be performed on one machine on which the issue appears.

Sorry, but that’s impossible. The issue appears on a production machine. I can’t execute my tests on it. I’m trying to reproduce it as well as I can…

This morning, after seeing that the result differs from one machine to another, I’ve installed all the windows fonts on my unix machine… Since then, the issue has disapeared.

Thanks for your help, you asked me the right questions and you helped me find the solution. If the issue appears again, I will contact you again! I hope that installing the windows font has solved the problem.

Here is the XPS you asked for (if you see something, don’t hesite to tell me :slight_smile: )
result.xps.zip (1.0 MB)

@rodrigue.leopold As far as I understand, this xps is from the machine on which the issue is no longer reproduced, since I don’t see any problems in it. Unfortunately, this is not informative. In any case, let us know whether the issue has been resolved on your production machine.