Me and my team members experience a problem we believe is a bug - we use Aspose.Words to generate a word document from a template, and we end up with wrong page number in the table of contents (TOC) that is solved only by manually update the TOC.
We use the library in Dotnet core container, and this bug also reproduce on our MAC development PCs.
I attached a ZIP file with a small program that reproduces the bug.
In order to run it you should add the license file, run it in CLI and check the generated document.
The zip contains the current word document with wrong page numbers, and contains a clear readme of how to run (although it’s straightforward).
We have tested the scenario using the latest version of Aspose.Words for .NET 20.8 and have not found the shared issue. So, please use Aspose.Words for .NET 20.8. We have attached the output DOCX with this post for your kind reference. 20.8.zip (88.2 KB)
Hi Tahir, Thanks for the quick response.
However, It didn’t solve my problem, as you can see in the ZIP I attached we are already using version 20.8 - as can be seen in the csproj file :
example_for_mismatch_page_numbers_in_generated_report.docx - This is the report generated by Asspose with the bug
example_for_mismatch_page_numbers_in_generated_report_after_manual_update.docx - this is the same report after I manually update TOC (right click update and choosing entrire table)
I checked the document you attached and it looks like it is correct and doesn’t have the bug in it.
Note that we’re using dotnet core docker container. I created the example project inside a container I already have with more applications, so it will be hard to share the Dockerfile as is, but I copied the relevant part from it so you could modify it and build a container :
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
RUN apt-get update && apt-get install -y libfontconfig1 \
&& rm -rf /var/lib/apt/lists/*
COPY . .
RUN dotnet restore
RUN dotnet publish -c release -o /app
WORKDIR /app
COPY ./<Example Project Directory>
It looks like this issue is not related to Aspose.Words. The page number of last TOC item is 6. When you click on this link, you will notice that MS Word moves the cursor to 6th page. However, MS Word incorrectly updates the page number to 5.
Hi Tahir,
We managed to reproduce the issue with another template in a way that it’s more significant and it can be seen it’s not an MS Word issue - in this example, you can see the TOC tells us the last paragraph is on page 21 although there are only 16 pages in the document (including page 0 which is the page that MS word is not numbering).
See the updated project and outcome document attached.
Please advise, Thanks,
Roni
The issue you are facing is actually not a bug in Aspose.Words. So, we have closed this issue WORDSNET-21061 as ‘Not a Bug’.
Please install all fonts used in your document at MAC system to get the desired output. You can implement IWarningCallback interface and save document to PDF to get notification for missing fonts on your system.
The page numbers of table of content are related to page layout of document. If the fonts are not installed on the system, the page layout will be incorrect and page numbers will also be incorrect. To check this scenario, you can implement IWarningCallback interface and save the document to PDF for missing font notification. The page layout of PDF document will be incorrect if the fonts are missing on the system.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.