We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Page Count of Current Document

How can I get the total page count of an existing doc? If I open a file like

WordDocument doc = new WordDocument( filename );

Is there an API method or property to get total number of pages in the doc?

8 Replies

RS Rolf Stocker September 7, 2010 01:08 PM

I think I found it at:


GT Gunasekaran T Syncfusion Team September 8, 2010 03:56 AM

Hi Rolf,

Thank you for using Syncfusion products.

We are glad to know that you have found out the solution by yourself.
The “BuildInDocumentProperties.PageCount” returns the value of page count stored in the document level. In some cases the values stored in the document property may be incorrect/ wrong, this is due to the following reasons:
1) Values of Built in document properties stored in the document may be out of date; this can be overcome by invoking the word count option and resaving the document using MS word.
2) MS Word show page count & line count values calculated on the fly (runtime).
Since DocIO returns the exact value stored in the document property, the page count value may differ in some cases. We can verify the page count value return by the DocIO; by opening the document properties (Right click on the document and select properties).

Please get in touch with us, if you require any further assistance.


RS Rolf Stocker September 8, 2010 04:38 AM

I am indeed finding that the property may not reflect reality. In my case I'm building a doc package in memory by merging in different sections. Ideally I could get the page count as I'm adding these different sections without having to go to some kind of save. Is there another technique which gets me an accurate and current page count of in-memory WordDocument?

GT Gunasekaran T Syncfusion Team September 9, 2010 03:33 AM

Hi Rolf,

Thank you for your update.

Currently DocIO does not have support for retrieving the accurate page count values and the page number of the Word Document. DocIO retrieves the page count values present in the document property of the Word document. It does not update the page count and line count values at run time. To update these values at run time, DocIO needs to have a lay outing algorithm. Currently it is not available with DocIO, hence we are not able to get the accurate page count and line count values.

Please let us know if you have any queries.


A A August 18, 2016 07:58 AM


I want to know if the old issue with "doc.BuiltinDocumentProperties.PageCount" has been resolved?

Another question: I have added a "NumPages" field to the document to show the page count. However, it shows a wrong value after invoking the "UpdateDocumentFields" method. If I open the same document with MS Word and update the field manually, it shows the correct number.


SV Sivasubramani V Syncfusion Team August 19, 2016 05:08 AM

Hi Customer,

Thank you for your update.

The latest DocIO version provides the support for retrieving the page count from "doc.BuiltinDocumentProperties.PageCount"

Can you please let us know, Which version you are using to reproduce this issue. And also update us your exact working scenario with the input document and the code snippets used your end to reproduce the issue? Thereby we will analyze on your requirement and update you the appropriate solution


CN Clint Nelson February 19, 2018 09:31 AM

I am having an issue in Xamarin.DocIO where page count is incorrect(web preview only) when adding sections to a word document template. Page count always shows "1" (see attachment), I assume based on the page template count, no matter how many pages I end up with.

“BuiltInDocumentProperties.PageCount” is readonly. Is there a way to assign a value to this?

When the document is opened in Word or Google Docs then the page count is corrected automatically.

MJ Mohanaselvam Jothi Syncfusion Team February 20, 2018 04:18 AM

Hi Clint,

Thank you for your update.

Regarding “BuiltInDocumentProperties.PageCount” is readonly. Is there a way to assign a value to this?
No, there is no way to assign a value to WordDocument.BuiltinDocumentProperties.PageCount property using DocIO. Since, Microsoft Word doesn’t allow to change this property manually by users.

Regarding “When the document is opened in Word or Google Docs then the page count is corrected automatically”:
The Word document is a flow document in which contents will not be preserved page by page; instead the contents will be preserved sequentially section by section. Each section may extend to various pages based on its contents like table, text, images etc.

The applications like Microsoft Word and Google docs, renders the contents of the Word document page by page dynamically when opened for viewing or editing. Also, updates the page count property based on the rendered information. Whereas DocIO is a non-UI component that maintains the content in the flow document structure and doesn’t render the contents page by page dynamically. Hence, DocIO returns the page count, stored in file level (updated earlier by other Word viewer/editor applications) and doesn’t automatically update on adding or removing the contents (sections, paragraphs, etc.).

To meet your requirement to get page count after modifying the Word document, use
UpdateWordCount method of DocIO which renders the content page by page and update the page count property.
Please refer the below code example to update the
PageCount property using DocIO. 
//Creates an empty WordDocument instance 
WordDocument document = new WordDocument(); 
//opens an existing word document through Open method of WordDocument class 

//To-Do some manipulation

//Updates the Paragraphs count, Word count, Character count, and Page count. 
//Gets the updated page count value. 
int count = document.BuiltinDocumentProperties.PageCount; 
//Saves the document in file system 
document.Save(outputFileName, FormatType.Docx); 
1. The mentioned
UpdateWordCount method internally uses Word to PDF conversion process to calculate the page count. So, the limitations of Word to PDF conversion is applicable in this case.
Please refer the below UG documentation link for more information.
2. The
UpdateWordCount method is not supported in Xamarin platform.

Please let us know if you have any other questions.

Mohanaselvam J

Live Chat Icon For mobile
Up arrow icon