TableAbsorber

Inheritance: java.lang.Object

public class TableAbsorber

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");

Constructors

ConstructorDescription
TableAbsorber(TextSearchOptions textSearchOptions)Initializes a new instance of the TableAbsorber with text search options.
TableAbsorber()Initializes a new instance of the TableAbsorber .

Methods

MethodDescription
getTextSearchOptions()Gets text search options.
setTextSearchOptions(TextSearchOptions value)Gets or sets text search options.
getTableList()Returns readonly IList containing tables that were found
isUseFlowEngine()Enable an alternative table recognition engine that is superior in numerous scenarios and is capable of recognizing tables without borders.
setUseFlowEngine(boolean useFlowEngine)Enable an alternative table recognition engine that is superior in numerous scenarios and is capable of recognizing tables without borders.
visit(Page page)Extracts tables on the specified page
visit(IDocument pdf)Extracts tables on the specified document.
remove(AbsorbedTable table)Removes an AbsorbedTable from the page.
replace(Page page, AbsorbedTable oldTable, Table newTable)Replaces an AbsorbedTable with Table on the page.

TableAbsorber(TextSearchOptions textSearchOptions)

public TableAbsorber(TextSearchOptions textSearchOptions)

Initializes a new instance of the TableAbsorber with text search options.

Parameters:

ParameterTypeDescription
textSearchOptionsTextSearchOptionsText search options

Performs searching for tables and provides access to the tables via TableList object. |

TableAbsorber()

public TableAbsorber()

Initializes a new instance of the TableAbsorber .


Performs searching for tables and provides access to the tables via TableList object.

getTextSearchOptions()

public TextSearchOptions getTextSearchOptions()

Gets text search options.


Allows to define several options that will be used during search text containing in tables.

Returns: TextSearchOptions - TextSearchOptions object

setTextSearchOptions(TextSearchOptions value)

public void setTextSearchOptions(TextSearchOptions value)

Gets or sets text search options.


Allows to define several options that will be used during search text containing in tables.

Parameters:

ParameterTypeDescription
valueTextSearchOptionsTextSearchOptions object

getTableList()

public List<AbsorbedTable> getTableList()

Returns readonly IList containing tables that were found

Returns: java.util.List<com.aspose.pdf.AbsorbedTable> - IGenericList object

isUseFlowEngine()

public boolean isUseFlowEngine()

Enable an alternative table recognition engine that is superior in numerous scenarios and is capable of recognizing tables without borders.

Returns: boolean - boolean value

setUseFlowEngine(boolean useFlowEngine)

public void setUseFlowEngine(boolean useFlowEngine)

Enable an alternative table recognition engine that is superior in numerous scenarios and is capable of recognizing tables without borders.

Parameters:

ParameterTypeDescription
useFlowEnginebooleanboolean value

visit(Page page)

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(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");

Parameters:

ParameterTypeDescription
pagePagePdf document page object.

visit(IDocument pdf)

public void visit(IDocument pdf)

Extracts tables on the specified document.


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);
 // 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");

Parameters:

ParameterTypeDescription
pdfIDocumentPdf document object.

remove(AbsorbedTable table)

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.

Parameters:

ParameterTypeDescription
tableAbsorbedTableAbsorbedTable to remove.

replace(Page page, AbsorbedTable oldTable, Table newTable)

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.

Parameters:

ParameterTypeDescription
pagePagePdf pocument page object.
oldTableAbsorbedTableAbsorbedTable to be replaced.
newTableTableTable to replace old table.