Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Mar 22, 2012 8:11 am

Hi There,
how can I count pages of the word-document.
The following code doesn't work:

(C#)
fileName = @"\D:\doc_with_3_pages.doc";
Spire.Doc.Document doc = new Spire.Doc.Document();
doc.LoadFromFile(fileName);
int number_of_pages = doc.BuiltinDocumentProperties.PageCount;

// number_of_pages should be 3, because the document has 3 Pages
// but number_of_pages == 1

Rgds,
Maik

maikludwig
 
Posts: 1
Joined: Fri Dec 17, 2010 11:17 am

Fri Mar 23, 2012 7:59 am

Hi Maik,

Thanks for your inquiry.

We are so sorry that Spire.Doc can't support to count the pages of a word-document at this present. But you can display the amount of the pages in a word-coument using the following code:
footerParagraph.AppendField("number of pages", FieldType.FieldNumPages);

The code above can diaplay the number of pages at a specific location. But we can't get the amount of the pages as an int variable.

Sorry for the inconvenience.
Have a nice day.

Kind Regards
Suvi
e-iceblue support
User avatar

Suvi.Wu
 
Posts: 154
Joined: Thu Oct 20, 2011 2:53 am

Return to Spire.Doc