Thanks for your request. Aspose.Words has introduced a new Layout namespace that provides classes allowing access to information such as on what page and where on a page particular document elements are positioned, when the document is formatted into pages.
For example, the LayoutCollector class collects mapping of document nodes to layout objects and computes page numbers of nodes.
When you create a LayoutCollector and specify a Document document object to attach to, the collector will record mapping of document nodes to layout objects when the document is formatted into pages.
You will be able to find out on which page a particular document node (e.g. run, paragraph or table cell) is located by using the GetStartPageIndex, GetEndPageIndex and GetNumPagesSpanned methods. These methods automatically build page layout model of the document and update fields if required.
Moreover, when you no longer need to collect layout information, it is best to set the Document property to null to avoid unnecessary collection of more layout mappings.
In addition, please try using the following sample code snippet:
doc = new Document(@“C:\temp\in.docx”);
LayoutCollector lc = new LayoutCollector(doc);
target = null;
foreach (Paragraph para in
// Get the
paragraph you want to find the Page Number of
target = para;
(target != null)
I hope, this helps.