using System.Collections.Generic;
using GemBox.Document.Tables;
public static void Main()
GemBox.Pdf.ComponentInfo.SetLicense("FREE-LIMITED-KEY");
GemBox.Document.ComponentInfo.SetLicense("FREE-LIMITED-KEY");
GemBox.Document.ComponentInfo.FreeLimitReached += (sender, e) =>
e.FreeLimitReachedAction = GemBox.Document.FreeLimitReachedAction.Stop;
var doc = _LoadPdfFile(@"https://www.gemboxsoftware.com/document/examples/305/resources/CustomInvoice.pdf");
var firstRow = _GetTablesFromPdf(doc)[2].Rows[1].Cells.Content.ToString();
Console.WriteLine(firstRow);
var secondRow = _GetTablesFromPdf(doc)[2].Rows[2].Cells.Content.ToString();
Console.WriteLine(secondRow);
static DocumentModel _LoadPdfFile(string path, string password = null)
using (MemoryStream outputPdfStream = new MemoryStream())
PdfDocument pdfDocument = password == null ?
PdfDocument.Load(path, new GemBox.Pdf.PdfLoadOptions()) :
PdfDocument.Load(path, new GemBox.Pdf.PdfLoadOptions {Password = password});
pdfDocument.SaveOptions.CrossReferenceType = PdfCrossReferenceType.Table;
pdfDocument.SaveOptions.Encryption = null;
pdfDocument.Save(outputPdfStream);
return DocumentModel.Load(outputPdfStream);
private static List<Table> _GetTablesFromPdf(DocumentModel document)
List<Table> tables = new List<Table>();
foreach (Section section in document.Sections)
foreach (Element child in section.GetChildElements(true, ElementType.Table))
Table table = (Table) child;