Document.PageCount is inconsistent with the microsoft word page count when invoke the Document.UpdateTableLayout method using C# .NET

hello experts,

I ran into a problem when use document.PageCount property to get document pages is inconsistent with the page count of the microsoft word.

The document (1.5 MB) , i had installed the font size of (929.9 KB) in window.

The follow is my code:
var doc =new Document(@“c:\Paper.docx”);
doc.PageCount; //return 89, consistent with the word page count.
doc.PageCount; //return 91, inconsistent with the word page count ,the word page count still 89

For some reason, i must invoke the doc.UpdateTableLayout() method.

so, for this inconsistency, any suggestions for us or some background to avoid the situation.



But, MS Word 2019 on our end reports that there are actually 78 pages in the “Paper.docx” file. We have already installed the Font files that you have provided. What version of MS Word are you using on your end?

And Aspose.Words for .NET 20.5 reports that there are 77 pages before and even after calling UpdateTableLayout method, the count remains the same i.e. 77. Can you please upgrade to the latest version of Aspose.Words and see how it goes on your end?

Thanks for your reply,

we use the Office 365 and Aspose.Words for .NET 19.8.

In order to get the document pages, we also customize a extend method like the below code:

public static int SpecialPageCount(this Document doc)
var builder = new DocumentBuilder(doc);

        builder.Document.FontSettings = new Aspose.Words.Fonts.FontSettings();
        builder.Document.FontSettings.SetFontsFolder(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Font", "OpenDyslexic"), true);
        return builder.Document.PageCount;

And Aspose.Words for .NET 19.8 reports that there are 89 pages before and 91 pages after calling UpdateTableLayout method, the MS Words pages inconsistency with the Aspose API that caused us a lot of trouble.

so, neither the 78、 89 or 77、 91, we want the API to be consistent with MS Words.

But for the specificity of the project, we couldn’t upgrade the lasted version of Aspose.Words.


Please also convert your input DOCX (Paper.docx) Word document to PDF and XPS formats by using ‘Save As’ command of MS Word on your end, ZIP and attach the PDF & XPS files here for further testing. Thanks for your cooperation.

The follow .zip is PDF formats by Paper.docx converted
paper (6.9 MB)


We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-20538. We will further look into the details of this problem and will keep you updated on the status of the linked issue. Sorry for the inconvenience.


Please also produce two more PDF files by using the following code snippets on your end and share both the PDF files here for further testing:

Code 1:

Document doc = new Document("E:\\Paper\\Paper.docx");

Code 2:

Document doc = new Document("E:\\Paper\\Paper.docx");

Thanks for your cooperation.


We are waiting for your further input on this topic (WORDSNET-20538). Please see my previous post and share the requested PDF files. Thanks for your cooperation.


I’m sorry for your waiting.

The follow are the pdf files using Aspose.Words for .NET 19.8

20.6.pdf (1.9 MB)
20.6-UpdateTableLayout.pdf (1.9 MB)

And using Aspose.Words for .NET latest 20.10
20.10.pdf (1.9 MB)
20.10-UpdateTableLayout.pdf (1.9 MB)


We have logged these details in our issue tracking system and will keep you posted here on any further updates.


On reviewing your outputs, it seems that most of the layout differences causing page count mismatch are related to different line spacing between the expected result and Aspose.Words output. For that, we had logged a separate issue with ID WORDSNET-21224. And now we have completed the analysis of WORDSNET-21224 and here are the details:

We are of the opinion that none of the OpenDyslexic fonts you provided ( is used in this 20538.expected office 365 from customer.pdf (8.3 MB). The comparison of glyphs for the “0” character confirms that.

For 20538.expected office 365 from customer.pdf, please check this screenshot:

And for 20.6.pdf and 20.10.pdf you provided, see following screenshot:

We suggest you please to do the following on your end:

  1. Double check that Aspose.Words and Office 365 are using the same font. Office 365 might use a cloud font instead of the installed one in C:\Windows\Fonts. The cloud fonts are located in C:\Users\ <username> \AppData\Local\Microsoft\FontCache.
  2. Save the document to PDF and XPS in Word 365 and provide these PDF and XPS to us. For some reason, all text using OpenDyslexic in 20538.expected office 365 from customer.pdf is stored as images. Because of this we cannot check what font and its version were used originally.

Thanks for your cooperation.