We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page Number of Paragraph


How can I get page number of Paragraph object? I know that a paragraph may spread out multiple pages. Getting all pages numbers containing the paragraph or just starting page is sufficient.


Hi Huseyin,

Thanks for your inquiry. You will be able to find out on which page a particular document node (e.g. Paragraph) is located by using the LayoutCollector.GetStartPageIndex, LayoutCollector.GetEndPageIndex and LayoutCollector.GetNumPagesSpanned methods. These methods automatically build page layout model of the document and update fields if required. You can use the following sample code to determine the Page number of a Paragraph:

Document doc = new Document(@"C:\temp\in.docx");
LayoutCollector lc = new LayoutCollector(doc);
Paragraph target = null;
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
    // Get the paragraph you want to find the Page Number of
    target = para;
if (target != null)

I hope, this helps.

Best regards,

Hi Awais,

It was what i’ve required.

Thank you,