什么方法能获取word文档准确的总页数
使用过poi,apose,大部分word文档都能正确获取文档总页数,但有些文档不能获得正常页数,在一些在线打印平台上传文件测试却可以准确读出来,但不知道用的什么方法,我用的poi代码如下:
if(type.equals(".doc")){
HWPFDocument doc = new HWPFDocument(new FileInputStream(filepath));
int pages = doc.getSummaryInformation().getPageCount();//总页数
return pages;
}else if(type.equals("docx")){
XWPFDocument docx = new XWPFDocument(POIXMLDocument.openPackage(filepath));
int pages = docx.getProperties().getExtendedProperties().getUnderlyingProperties().getPages();//总页数
return pages;
}
请问有什么好的方法吗