Iterate through the collection and print table cells.
The following example shows how to extract tables from the whole document:
// Create an instance of Parser class
try(Parserparser=newParser(Constants.SampleInvoicePagesPdf)){// Check if the document supports table extraction
if(!parser.getFeatures().isTables()){System.out.println("Document isn't supports tables extraction.");return;}// Create the layout of tables
TemplateTableLayoutlayout=newTemplateTableLayout(java.util.Arrays.asList(newDouble[]{50.0,95.0,275.0,415.0,485.0,545.0}),java.util.Arrays.asList(newDouble[]{325.0,340.0,365.0,395.0}));// Create the options for table extraction
PageTableAreaOptionsoptions=newPageTableAreaOptions(layout);// Extract tables from the document
Iterable<PageTableArea>tables=parser.getTables(options);// Iterate over tables
for(PageTableAreat:tables){// Iterate over rows
for(introw=0;row<t.getRowCount();row++){// Iterate over columns
for(intcolumn=0;column<t.getColumnCount();column++){// Get the table cell
PageTableAreaCellcell=t.getCell(row,column);if(cell!=null){// Print the table cell text
System.out.print(cell.getText());System.out.print(" | ");}}System.out.println();}System.out.println();}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: