您好,之前说collector.getStartPageIndex(row)识别错误的问题是由于试用版导致的。我这边购买了OEM版本后,这个函数识别依然是错误的。请求帮助。代码和测试文件粘贴如下:
public static void main(String[] args) throws Exception {
//"C:\\Users\\11964\\Desktop\\Aspose.Words.Java.lic"
License license = new License();
license.setLicense("C:\\\\Users\\\\11964\\\\Desktop\\\\Aspose.Words.Java.lic");
Document doc = new Document("C:\\Users\\11964\\Desktop\\test续表.docx");
LayoutCollector collector = new LayoutCollector(doc);
Node[] nodeArray = doc.getChildNodes(NodeType.ANY,true).toArray();
for (Node node: nodeArray) {
if (node instanceof Table table) {
System.out.println(node.getText());
Row columnHeaders = findTableHead(table);
int firstPageIndex = collector.getStartPageIndex(columnHeaders);
RowCollection rows = table.getRows();
for (Row row : rows) {
if (firstPageIndex != collector.getStartPageIndex(row)) {
System.out.println("\n不一致");
System.out.println(row.getText());
System.out.println(firstPageIndex);
System.out.println(collector.getEndPageIndex(row));
}
}
}
}
doc.save("C:\\Users\\11964\\Desktop\\output.docx");
}
测试文件如下:
test续表.docx (17.6 KB)
测试结果如下:
不一致
a(0.0000)a(0.0586)a(0.0000)a(0.0585)aa
1
2
不一致
Leva-0.0007***a-2.4121***a-0.0007***a-2.4044***aa
1
2
不一致
a(0.0001)a(0.1593)a(0.0001)a(0.1592)aa
1
2
目前识别的还是错位的。程序认为的的第二页第一行其实是第一页倒数第二行。请问如何解决