使用Python的Word文档的页数 [英] Number of pages of a word document with Python

查看:2228
本文介绍了使用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

这篇关于使用Python的Word文档的页数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆