Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Oct 18, 2023 5:57 am

使用如下的示例代码解析pdf中的表格,对于左侧没有边框线的表格(如附件),会缺少第一列的信息,是否有解决方案,谢谢


for (int pageIndex = 0; pageIndex < pdf.getPages().getCount(); pageIndex++) {
//Extract tables from the current page into a PdfTable array
PdfTable[] tableLists = extractor.extractTable(pageIndex);

//If any tables are found
if (tableLists != null && tableLists.length > 0) {
//Loop through the tables in the array
for (PdfTable table : tableLists) {
//Loop through the rows in the current table
for (int i = 0; i < table.getRowCount(); i++) {
//Loop through the columns in the current table
for (int j = 0; j < table.getColumnCount(); j++) {
//Extract data from the current table cell and append to the StringBuilder
String text = table.getText(i, j);
builder.append(text + " | ");
}
builder.append("\r\n");
}
}
}
}

peterxie
 
Posts: 2
Joined: Mon Feb 06, 2023 6:31 am

Wed Oct 18, 2023 7:33 am

您好,

感谢您的咨询。
PDF本身是不存在表格这个概念的,我们的产品解析所谓的表格实际上是通过水平线条或者垂直线条是否交叉来判断的。如果使用最新商业版本提取不到,那目前也没有其他解决方案。感谢您的理解与支持。

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.PDF