Pdf for java 怎么获得单元格的rowspan?

我的使用环境如下:
1、使用的组件名称:pdf
2、使用的开发语言:JAVA
3、使用的组件版本号:25.5
问题如下:
java版本pdf25.5中表格的单元格只有colspan的方法?没有rowspan,怎么获得单元格的rowspan?我们现在需要做的是解析这个表格,并获得当前表格中每个单元格的位置以及colspan和rowspan,DEMO示例见附件。
https://c.wss.pet/f/hcg7bs9uv38 复制链接到浏览器打开

@Angela_xu

Cause

In Aspose.PDF for Java version 25.5, you can retrieve the rowspan of a cell in a table using the Cell class, which provides the getRowSpan() method to obtain the row span of a specific cell.

Solution

To get the rowspan of a cell, utilize the getRowSpan() method from the Cell class. Typically, you will iterate through the cells in your table and call this method for each cell to retrieve its rowspan.

Code

Here’s a simple example demonstrating how to extract the rowspan for each cell in a table:

import com.aspose.pdf.*;

public class PdfTableRowSpan {
    public static void main(String[] args) {
        // Load the PDF document
        Document pdfDocument = new Document("path/to/your/document.pdf");

        // Create a TableAbsorber to extract tables
        TableAbsorber tableAbsorber = new TableAbsorber();
        tableAbsorber.visit(pdfDocument);

        // Iterate through the tables
        for (Table table : tableAbsorber.getTableList()) {
            for (Row row : table.getRows()) {
                for (Cell cell : row.getCells()) {
                    int rowSpan = cell.getRowSpan();
                    System.out.println("Cell at Row " + row.getRowIndex() + ", Column " + cell.getColumnIndex() + " has rowspan: " + rowSpan);
                }
            }
        }
    }
}

Next Steps

  1. Ensure you have the correct version of Aspose.PDF for Java (25.5) in your project.
  2. Replace "path/to/your/document.pdf" with the actual path to your PDF file.
  3. Run the code to see the row spans of each cell printed in the console.

If you have any further questions or need additional assistance, feel free to ask!

1.jpg (137.8 KB)

2.jpg (177.8 KB)

按照以上方法测试后,发现代码形参类型不对,还请帮忙看看。

请问三天前发的报错,有看到吗?今天能有回复吗?

@Angela_xu

很抱歉回复迟了。我们已经查看了您的评论和要求。我们需要调查您的要求是否可以实现。我们尝试从您提供的链接下载资源,但无法访问。您能否将其上传到 Google Drive、Dropbox 或其他公共共享平台?我们将进一步为您提供相应的帮助。

https://c.wss.pet/f/hdh8ip349hn 复制链接到浏览器打开,已经重新传了报错截图,请查收

@Angela_xu

是的,我们已经发现并确认了问题所在。请您分享一下您的示例 PDF 文档和您正在使用的完整代码片段。我们会记录调查工单并与您分享 ID。

文叔叔 - 传文件,找文叔叔(永不限速) 复制链接到浏览器打开,PDF和代码,已经上传,请查收。

@Angela_xu

我们已在内部问题跟踪系统中打开以下新工单,并将根据 Free Support Policies 中所述的条款提供修复。

问题 ID:PDFJAVA-45141

如果您需要优先支持,并可以直接联系我们的付费支持管理团队,您可以访问 Paid Support Services