Iterate through the collection and print table cells.
The following example shows how to extract tables from the document page:
// Create an instance of Parser classusing(Parserparser=newParser(filePath)){// Check if the document supports table extractionif(!parser.Features.Tables){Console.WriteLine("Document isn't supports tables extraction.");return;}// Create the layout of tablesTemplateTableLayoutlayout=newTemplateTableLayout(newdouble[]{50,95,275,415,485,545},newdouble[]{325,340,365,395});// Create the options for table extractionPageTableAreaOptionsoptions=newPageTableAreaOptions(layout);// Get the document infoIDocumentInfodocumentInfo=parser.GetDocumentInfo();// Check if the document has pagesif(documentInfo.PageCount==0){Console.WriteLine("Document hasn't pages.");return;}// Iterate over pagesfor(intpageIndex=0;pageIndex<documentInfo.PageCount;pageIndex++){// Print a page number Console.WriteLine(string.Format("Page {0}/{1}",pageIndex+1,documentInfo.PageCount));// Extract tables from the document pageIEnumerable<PageTableArea>tables=parser.GetTables(pageIndex,options);// Iterate over tablesforeach(PageTableAreatintables){// Iterate over rowsfor(introw=0;row<t.RowCount;row++){// Iterate over columnsfor(intcolumn=0;column<t.ColumnCount;column++){// Get the table cellPageTableAreaCellcell=t[row,column];if(cell!=null){// Print the table cell textConsole.Write(cell.Text);Console.Write(" | ");}}Console.WriteLine();}Console.WriteLine();}}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: