我的使用环境如下:
1、使用的组件名称:pdf
2、使用的开发语言:JAVA
3、使用的组件版本号:25.5
问题如下:
java版本pdf25.5中表格的单元格只有colspan的方法?没有rowspan,怎么获得单元格的rowspan?我们现在需要做的是解析这个表格,并获得当前表格中每个单元格的位置以及colspan和rowspan,DEMO示例见附件。
https://c.wss.pet/f/hcg7bs9uv38 复制链接到浏览器打开
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
- Ensure you have the correct version of Aspose.PDF for Java (25.5) in your project.
- Replace
"path/to/your/document.pdf"
with the actual path to your PDF file. - 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!
请问三天前发的报错,有看到吗?今天能有回复吗?
很抱歉回复迟了。我们已经查看了您的评论和要求。我们需要调查您的要求是否可以实现。我们尝试从您提供的链接下载资源,但无法访问。您能否将其上传到 Google Drive、Dropbox 或其他公共共享平台?我们将进一步为您提供相应的帮助。
我们已在内部问题跟踪系统中打开以下新工单,并将根据 Free Support Policies 中所述的条款提供修复。
问题 ID:PDFJAVA-45141
如果您需要优先支持,并可以直接联系我们的付费支持管理团队,您可以访问 Paid Support Services。