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

Free Support Forum - aspose.com

How to get current page number


I can’t find this in the documentation : how to retrieve the current page number of a node?
I’d like to add a page break on a certain condition (if i’m on page X or not for example).

Any idea how to do this?

I’m under Aspose.Words for .NET

Thank you for your support.


Hi Chris,

Thanks for your inquiry.

Please use LayoutCollector.GetStartPageIndex method to get the page number of a node. This method gets 1-based index of the page where node begins. Note that this method is not available in older version of Aspose.Words. Please upgrade to latest version of Aspose.Words for .NET 15.12.0 and let us know if you have any more queries.

And it seems not to be useable to get the footer page number?


Thanks for your inquiry. Yes, your understanding is correct. HeaderFooter is a section-level node and can only be a child of Section. The LayoutCollector.GetStartPageIndex returns 0 if node cannot be mapped to a page.

Best Regards,
Tahir Manzoor