Get Page number of Node or Shape?

Good evening,

when iterating over a Document’s Nodes / NodeCollection, is there any way to find out what page these Nodes and/or Shapes are on?

Thanks
-JB

Hi Joerg,

Thanks for your inquiry. You may use GetStartPageIndex method of LayoutCollector class, It returns 1-based index of the page where node begins. Returns 0 if node cannot be mapped to a page.

Please note Aspose.Words.Layout namespace provides classes those allow to access information such as on what page and where on the page particular document element(Node) is positioned, when the document is formatted into pages.

LayoutCollector layout = new LayoutCollector(doc);
foreach (Paragraph paragraph in doc.GetChildNodes(NodeType.Paragraph, true))
{
    Console.Out.WriteLine(layout.GetStartPageIndex(paragraph));
…

Best Regards,