如何在java中获取microsoft word文档的页数?
对于基于服务器的j2ee应用程序,我需要从word文档中检索页数..有什么想法有效吗?
for a server based j2ee application, I need to retrieve the number of pages from word documents.. any ideas what works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果文档是现代 Word 2007 格式,您可以通过
如果它们是较旧的 Word 格式,您可能会陷入服务器端 Word/Excel/Powerpoint/Outlook 可编程对象模型,尽管 你不应该在服务器上这样做..
If the documents are modern Word 2007 format you can use direct XML-based manipulation, through OOXML. This is by far the better long term solution, though I realize it may not be realistic for an entire organization to change overnight.
If they are older Word formats, you're probably stuck with server-side Word/Excel/Powerpoint/Outlook programmable object models, although you're not supposed to do that on the server..
关于 Office Open XML 支持,Java-POI 的最新测试版应该支持它。
Regarding Office Open XML support, the latest beta of Java-POI is supposed to support it.
以前没有使用过它,但您可以尝试 Apache POI。 看起来它有一个 WordCount功能。
Haven't used it before but you could try Apache POI. Looks like it has a WordCount function.
//打开Word文档
//获取页数
//Open the Word Document
//Get page count
要读取 MS Office 文件的页数,您可以使用 aspose 库(aspose-words、aspose-cells、aspose-slides)。
示例:
Excel:
工作簿可打印版本的页数:
Word: 页数:
PowerPoint: 幻灯片数量:
To read the page count of MS Office files you can use aspose libraries (aspose-words, aspose-cells, aspose-slides).
Examples:
Excel:
number of pages of the printable version of the Woorkbook:
Word: number of pages:
PowerPoint: number of slides: