DocumentPageCount Property
Gets the number of pages in the document as calculated by the most recent page layout operation.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 20.1
public int PageCount { get; }

Property Value

Type: Int32
Shows how to invoke page layout and retrieve the number of pages in the document.
Document doc = new Document(MyDir + "Document.doc");

// This invokes page layout which builds the document in memory so note that with large documents this
// property can take time. After invoking this property, any rendering operation e.g rendering to PDF or image
// will be instantaneous
int pageCount = doc.PageCount;
See Also