Reputation: 21002
I would like to count the number of pages in a RTF or MS Word document, using python. Is this possible?
Upvotes: 4
Views: 1958
Reputation: 123662
You could fire up Word, and use OLE automation to ask it for the number of pages.
Upvotes: 0
Reputation: 180808
Not without rendering the actual page.
The number of pages will depend on many things, such as the size of the fonts being used, the margins in all four directions on the page, and the insertion of any other sized artifacts such as images.
So what you would have to do is render the document in an RTF library of some sort, and let that library tell you how many pages there are.
Upvotes: 4