使用aspose.words for java V24.3试用版,转换word文档的时候,20页的文档使用wordDocument.getPageCount()返回25页,请问是什么原因,该怎么解决?
public static Map<String,Object> getFileDetail(String filePath){
Document wordDocument = null;
InputStream inputStream = null;
try {
inputStream = new FileInputStream(filePath);
wordDocument = new Document(inputStream);
// 获取第一页的页面大小
PageSetup pageSetup = wordDocument.getFirstSection().getPageSetup();
double pageWidth = pageSetup.getPageWidth();
double pageHeight = pageSetup.getPageHeight();
Map<String,Object> map = new HashMap<>();
map.put("total",wordDocument.getPageCount());
if (pageWidth > pageHeight) {
map.put("iv","0");
} else {
map.put("iv","1");
}
return map;
} catch (Exception e) {
e.printStackTrace();
return null;
}finally {
// 在finally块中将Document对象设置为null释放资源
wordDocument = null;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
1.docx (1.4 MB)