The Document.PageCount property returns 0 even though the document contains 203 pages

for a 203-page document, the PageCount function returns zero. Although there are 203 pages in the property of the document.

I tried doing an UpdatePageLayout on top of the document and then the PageCount returns 205 pages. 2 images will overflow to a new page.

I would need the same number of pages. You could take a look at it
Thank you in advance

@benestom Could you please attach your document here for testing? We will check the issue and provide you more information.
To calculate number of pages in the document Aspose.Words has to build document layout. To do this Aspose.Words needs the fonts used in the document. If the fonts are not available in the environment where layout is built Aspose.Words substitutes the missed fonts. This might cause layout difference and as a result incorrect page count. So, please, make sure the required fonts are available. You can implement IWarningCallback to get a notification when font substitution is performed.

for example, the image on page 187 after UpdatePageLayout 1P158pBefor.docx (7.2 MB)

@benestom The following fonts used in your document are not available on my machine. Could you please attach these fonts here for testing?

  • Futura CEZ Medium
  • Switzerland
  • Font 'Swis721 BlkOul BT
  • Toronto

Also, if open your document in MS Word on my side it should 208 pages in it.
By the way, if you would like to get the value of Pages stored in built-in document properties, you can use the following code:

Document doc = new Document(@"C:\Temp\in.docx");
Console.WriteLine(doc.BuiltInDocumentProperties.Pages);

But you should note, this property is not required to be updated, so it’s value might be incorrect.