使用Python的Word文档的页数

使用Python的Word文档的页数

问题描述:

是否可以使用Python有效地获取Word文档(.doc,.docx)的页数?

Is there a way to get efficiently the number of pages of a word document (.doc, .docx) with Python ?

对于.odt文件?

我想将其用于基于Linux上Web2py的Web应用程序.

I want to use this for a web application based on Web2py on Linux.

谢谢!

您可以读取值

<Properties>
<Pages>CountValue</Pages>

来自docx包中的docProps/app.xml或

from docProps/app.xml in the docx package or

<office:document-meta>
    <office:meta>
        <meta:document-statistic meta:page-count="CountValue">

在odt包中形成meta.xml.

form meta.xml in odt package.

如果这些值不存在(它们是可选的),则必须对整个文档进行计算,实际上执行渲染要困难得多

If these values ​​do not exist (they are optional), you have to make a calculation of the entire document, in fact perform rendering, that much more difficult