python-docx

number of pages in word document


is there a feature in python docx library to compute the number of pages in a document?


Solution

  • Not at the moment, but, unlike a way to tell where the page breaks are in the content, such a feature could be developed. At least if you were satisfied with whatever Word reported last time it saved the document.

    This statistic is saved in the app.xml properties "part" by Word on each save. So if you were confident the document you were inspecting had last been saved by Word (or LibreOffice I expect would work too), then that method should be pretty reliable. If the document were generated by, say, python-docx, that statistic would be unreliable.

    If this is a feature you're interested in, feel free to add it to the GitHub issues list: https://github.com/python-openxml/python-docx/issues