Identify the page number of a block of text

Is there are way to determine the page number of a block of text? I have noted the similar response from 2009.

@mokeefe

Thanks for your inquiry. You can use LayoutCollecter class to get page number of a particular document Node, when the document is formatted into pages.

Please use LayoutCollector.GetStartPageIndex method to get 1-based index of the page where node begins. This method returns 0 if node cannot be mapped to a page. For example, you can use the following sample code to determine the page number of a Paragraph Node. Hopefully it will help you to accomplish the task.

Document doc = new Document("input.docx");

LayoutCollector layout = new LayoutCollector(doc);

foreach (Paragraph paragraph in doc.GetChildNodes(NodeType.Paragraph, true))

{

Console.Out.WriteLine(layout.GetStartPageIndex(paragraph));

....