tabula-sharp
is a library for extracting tables from PDF files — it is a port of tabula-java
NuGet packages available on the releases page and on www.nuget.org:
NurminenDetectionAlgorithm
is replaced by SimpleNurminenDetectionAlgorithm
, because it requieres an image management library.using (PdfDocument document = PdfDocument.Open("doc.pdf", new ParsingOptions() { ClipPaths = true }))
{
ObjectExtractor oe = new ObjectExtractor(document);
PageArea page = oe.Extract(1);
// detect canditate table zones
SimpleNurminenDetectionAlgorithm detector = new SimpleNurminenDetectionAlgorithm();
var regions = detector.Detect(page);
IExtractionAlgorithm ea = new BasicExtractionAlgorithm();
List<Table> tables = ea.Extract(page.GetArea(regions[0].BoundingBox)); // take first candidate area
var table = tables[0];
var rows = table.Rows;
}
using (PdfDocument document = PdfDocument.Open("doc.pdf", new ParsingOptions() { ClipPaths = true }))
{
ObjectExtractor oe = new ObjectExtractor(document);
PageArea page = oe.Extract(1);
IExtractionAlgorithm ea = new SpreadsheetExtractionAlgorithm();
List<Table> tables = ea.Extract(page);
var table = tables[0];
var rows = table.Rows;
}