Free Support Forum - aspose.com

Iterate over document pages

Hi,
It is possible to iterate over the pages of a document?

I’m using document.getPageCount() but I don’t have any document.getPages().
I need to write a last paragraph at every pages of a document.

@fcri,

Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. In your case, you want to insert paragraph at the end of each page in the document. Please note that when you insert paragraph at the end of each page, the contents may flow to the next page.

You can achieve your requirement using Aspose.Words. You can insert paragraph at any place in the document. Please move the cursor to the desired paragraph and insert the paragraph.

To get the last paragraph of page, you need to iterate through paragraph nodes of document and get the page number of it. You can use LayoutCollector.GetStartPageIndex method to get the page number of Paragraph node.