问题
I am using XWPFDocument library to find number of pages in docx file. Below is my code snippet :
XWPFDocument docx = null;
try {
docx = new XWPFDocument(POIXMLDocument.openPackage(filePath));
totalPages = docx.getProperties().getExtendedProperties().getUnderlyingProperties().getPages();
} catch (IOException e) {
logger.error("Error while loading word document at file location {}", filePath);
totalPages = 0;
}
For some .docx it is working fine but for some files it is returning 1 inspite of having more than 30 pages.
来源:https://stackoverflow.com/questions/44650147/xwpfdocument-returning-1-number-of-pages-for-docx-file