It is not possible to get page numbers for a text document using OpanXml Sdk because it is being processed by the client (for example, MS Word).
However, if the document you are working with is previously opened by a text client and saved back, the client will add LastRenderedPageBreak to identify page breaks. See my answer here for more information on LastRenderedPageBreak s. This allows you to count the number of LastRenderedPageBreak elements LastRenderedPageBreak front of your paragraph to get the current page.
If this is not the case, then the noddy option to work with your requirement is to add footers with page numbers (maybe the same color as your documents to hide it!). Only option - if you automate the creation of a document using OpenXML sdk .
source share