Number of pages in doc, docx or rtf file using python

I would like to count the number of pages in an RTF or MS Word document using python. Is it possible?

+4
source share
2 answers

Not without displaying the actual page.

The number of pages will depend on many things, such as the size of the fonts used, the margins in all four directions on the page, and the insertion of any other artifacts, such as images.

So what you need to do is visualize the document in the RTF library, and let this library tell you how many pages there are.

+4
source

You can run Word and use OLE automation to ask it for the number of pages.

0
source

Source: https://habr.com/ru/post/1443740/


All Articles