Why are only some page numbers stored in the docx XML file?

I added the page number in the footer. This is visible in the document correctly. But if I unzip docx and check footer.xml, there will only be some random page numbers. since MS-Word can correctly display page numbers, and where does it store all page numbers?

0
xml ms-word docx
source share
1 answer

There is no logic as to which page numbers are stored in a Word Open XML document. In principle, the page numbers that you see in the header / footer section of Word Open XML are pointless because they will be automatically restored when you open the document and may not reflect the actual paging.

All dynamic content in Word, such as pagination, is field controlled. A field basically consists of two parts: a field code and a field result. You can see this structure in Word Open XML.

Depending on the type of field and its location, the fields will be automatically updated or an explicit update will be required. PAGE in the header / footer area is updated automatically, to a large extent during all editing in the Word user interface.

For fields that need to be explicitly updated, Word usually saves the last result in the document. But the fields that Word updates automatically may or may not store the last result. PLUS does not guarantee that the saved result will be right when you open the document the next time or when editing it. Depending on the particular machine, the page layout may change in fluidity when opening a document. Thus, any page numbers that you see in Open XML are not a guarantee that they will be there when the document is open.

The total number of pages, however, saved in the document properties may be correct - also depending on how the page layout is performed the next time the document is opened.

The following article contains some relevant information about updating a field: https://support.microsoft.com/en-us/help/211629/which-fields-are-updated-when-you-open--repaginate--or-print -document

+4
source share

All Articles