public class TableAbsorber extends Object
Represents an absorber object of table elements. Performs search and provides access to search
results via TableAbsorber.TableList
collection.
The example demonstrates how to find table on the first PDF document page and replace the text in a table cell. // Open document Document doc = new Document("D:\\Tests\\input.pdf"); // Create TableAbsorber object to find tables TableAbsorber absorber = new TableAbsorber(); // Visit first page with absorber absorber.visit(doc.getPages().get_Item(1)); // Get access to first table on page, their first cell and text fragments in it TextFragment fragment = absorber.getTableList().get_Item(0).getRowList().get_Item(0).getCellList().get_Item(0) .getTextFragments().get_Item(1); // Change text of the first text fragment in the cell fragment.setText("hi world"); // Save document doc.save("D:\\Tests\\output.pdf");
Constructor and Description |
---|
TableAbsorber()
Initializes a new instance of the
TableAbsorber . |
TableAbsorber(TextSearchOptions textSearchOptions)
Initializes a new instance of the
TableAbsorber with text search options. |
Modifier and Type | Method and Description |
---|---|
com.aspose.ms.System.Collections.Generic.IGenericList<AbsorbedTable> |
getTableList()
Returns readonly IList containing tables that were found
|
TextSearchOptions |
getTextSearchOptions()
Gets text search options.
|
void |
remove(AbsorbedTable table)
Removes an
AbsorbedTable from the page. |
void |
replace(Page page,
AbsorbedTable oldTable,
Table newTable)
Replaces an
AbsorbedTable with Table on the page. |
void |
setTextSearchOptions(TextSearchOptions value)
Gets or sets text search options.
|
void |
visit(Page page)
Extracts tables on the specified page
The example demonstrates how to extract table on the first PDF document page.
// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TableAbsorber object to find tables
TableAbsorber absorber = new TableAbsorber();
// Visit first page with absorber
absorber.visit(pdfDocument.getPages.get_item(1));
// Get access to first table on page, their first cell and text fragments in it
TextFragment fragment = absorber.getTableList().get_item(0).getRowList.get_item(0).getCellList().get_item(0)
.getTextFragments.get_item(1);
// Change text of the first text fragment in the cell
fragment.setText ("hi world");
// Save document
doc.save(@"D:\Tests\output.pdf");
|
public TableAbsorber(TextSearchOptions textSearchOptions)
Initializes a new instance of the TableAbsorber
with text search options.
textSearchOptions
- Text search options
TableList
object.public TableAbsorber()
Initializes a new instance of the TableAbsorber
.
TableList
object.public TextSearchOptions getTextSearchOptions()
Gets text search options.
public void setTextSearchOptions(TextSearchOptions value)
Gets or sets text search options.
value
- TextSearchOptions objectpublic com.aspose.ms.System.Collections.Generic.IGenericList<AbsorbedTable> getTableList()
Returns readonly IList containing tables that were found
IGenericList<AbsorbedTable> object
public void visit(Page page)
Extracts tables on the specified page
The example demonstrates how to extract table on the first PDF document page. // Open document Document doc = new Document(@"D:\Tests\input.pdf"); // Create TableAbsorber object to find tables TableAbsorber absorber = new TableAbsorber(); // Visit first page with absorber absorber.visit(pdfDocument.getPages.get_item(1)); // Get access to first table on page, their first cell and text fragments in it TextFragment fragment = absorber.getTableList().get_item(0).getRowList.get_item(0).getCellList().get_item(0) .getTextFragments.get_item(1); // Change text of the first text fragment in the cell fragment.setText ("hi world"); // Save document doc.save(@"D:\Tests\output.pdf");
page
- Pdf pocument page object.public void remove(AbsorbedTable table)
Removes an AbsorbedTable
from the page.
Please take into account it changes TableList collection. In case removing/replacing tables in loop please use copy of TableList collection.
table
- AbsorbedTable
to remove.public void replace(Page page, AbsorbedTable oldTable, Table newTable)
Replaces an AbsorbedTable
with Table
on the page.
Please take into account it changes TableList collection. In case removing/replacing tables in loop please use copy of TableList collection.
page
- Pdf pocument page object.oldTable
- AbsorbedTable
to be replaced.newTable
- Table
to replace old table.