[英]count the number of pages in a docx-document
I got a word file and I want to count how many pages are in it. 我有一个word文件,我想计算其中有多少页。
The file has been created with Docx4Java. 该文件已使用Docx4Java创建。
Anyone did this before? 有人做过吗?
Thanks! 谢谢!
docx4j doesn't have a page layout model, so it can't tell you a page count. docx4j没有页面布局模型,因此它不能告诉您页面数。
You can get an approximate page count by using FOP's page layout model. 您可以使用FOP的页面布局模型来获得大概的页面数。 docx4j's PDF output now supports a "2 pass" generation:
docx4j的PDF输出现在支持“ 2 pass”生成:
See https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/convert/out/fo/AbstractPlaceholderLookup.java and https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/convert/out/fo/ApacheFORenderer.java 参见https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/convert/out/fo/AbstractPlaceholderLookup.java和https://github.com/plutext/docx4j/blob /master/src/main/java/org/docx4j/convert/out/fo/ApacheFORenderer.java
So doing the first pass would give you (approximately) what you want. 因此,进行第一遍将(大约)给您您想要的。 This uses org.apache.fop.apps.FormattingResults which records the number of pages in a page sequence, or in the document as a whole.
这使用org.apache.fop.apps.FormattingResults来记录页面序列或整个文档中的页面数。
An alternative approach might be to use LibreOffice/OpenOffice (or Microsoft Word, for that matter). 一种替代方法是使用LibreOffice / OpenOffice(或Microsoft Word)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.