How to find the page number from a paragraph using OpenXML?
document, ms-word, openxml, page-numbering, paragraph
Solution
It is not possible to get page numbers for a word document using `OpanXml Sdk` as this is handled by the client (like MS Word).
However if the document you are working with is previously opened by a word client and saved back, then the client will add `LastRenderedPageBreak` to identify the page breaks. Refer to my answer here for more info about `LastRenderedPageBreak`s. This enables you to count for the number of `LastRenderedPageBreak` elements before your paragraph to get the current page count.
If this is not the case then the noddy option to work around your requirement is to add footers with page numbers (may be with same colour as your documents to virtually hide it!). Only an option - if you are automating the word document generation using `OpenXML sdk`.
Problem
For a Paragraph object, how can I determine on which page this is located using the Open XML SDK 2.0 for Microsoft Office ?