← All posts
by Arif Aslam 5 min read

How to Extract Tables from a PDF, Step by Step

PDF files are the default format for financial reports, government filings, invoices, and regulatory documents. The data is right there on the page, but getting it into a spreadsheet usually means copying cells one by one or paying for a SaaS extraction tool that uploads your files to a remote server.

ExploreMyData can extract tabular data from text-based PDFs directly in your browser. No upload, no server, no account. The file never leaves your machine.

How the parser works

The parser runs two detection modes and then reconciles what they found:

  1. Text and drawing extraction. The parser reads every text item on each page, recording its content and its x,y position, and it also reads the page's drawing operations. For scanned PDFs, browser-based OCR recognizes text from the page images instead.
  2. Fragment merging. PDF text is often split into many small fragments. The parser merges adjacent fragments on the same line into complete words and cell values, tracking character widths to distinguish cell boundaries from word spacing.
  3. Lattice pass. Where the page has ruled borders, the drawing operations are turned into line segments, clustered into a grid, and resolved into rectangular cells. Text chunks drop into the cells they sit in. This is the reliable path for invoices, lab reports, and forms.
  4. Stream pass. Anything the lattice pass didn't claim goes through borderless detection: rows are clustered by vertical position with a tolerance derived from the actual text height, then column boundaries are found with a region-growing algorithm inspired by Tabula. The parser seeds column regions from the most populated row, then grows each region by merging horizontally overlapping chunks from other rows. This handles right-aligned numbers and varying column widths naturally.
  5. Schema grouping. Tables that share a column count and header text are stacked into a single result, so a report whose table runs across eight pages arrives as one table rather than eight. Repeated page headers and other page furniture are stripped as they are stacked, and genuinely different schemas on the same document stay separate so you can pick between them on import.

For example, a quarterly revenue report with this layout in the PDF:

QuarterRevenueExpensesNet Income
Q1 20251,245,000892,000353,000
Q2 20251,380,000945,000435,000
Q3 20251,512,0001,023,000489,000
Q4 20251,688,0001,101,000587,000

...becomes exactly that table in ExploreMyData, ready for aggregation, charting, or export.

What works well

The parser performs best on PDFs with clearly structured, machine-readable text:

  • Financial statements with consistent column headers and numeric rows
  • Invoice line items where each row has a description, quantity, and amount
  • Government statistical tables published as PDF reports
  • Any PDF where you can select and copy text (this means it's text-based, not an image)

A quick test: open the PDF and try to highlight some text with your cursor. If you can select individual words, the parser can read it.

Scanned PDFs and OCR

If the PDF is a scanned image (no selectable text), ExploreMyData automatically falls back to browser-based OCR using tesseract.js. Each page is rendered to a canvas at roughly 300 DPI and then cleaned up (grayscale, then Otsu binarization) so the engine sees crisp black on white. The recognized text goes through the same table extraction pipeline as any other PDF.

This is done per page, so a document that is scanned in places and digital elsewhere only pays the OCR cost on the scanned pages. OCR works best with clear, high-resolution scans. Blurry pages, handwriting, or unusual fonts will reduce accuracy. It is limited to the first 10 scanned pages and to English, and it takes several seconds per page. A warning is shown when OCR is used, since recognition errors are possible.

Password-protected PDFs

If your PDF is password protected, ExploreMyData will prompt you to enter the password. The password is used locally in your browser to decrypt the file. It is never transmitted to any server. You get up to three attempts before the import is cancelled.

Known limitations

  • Merged cells and nested tables. The column detection assumes a regular grid. PDFs with cells spanning multiple columns or tables nested inside other tables may produce misaligned output.
  • Rotated pages. Translations, scales and rotations are all tracked, but a non-portrait rotation can still produce an unexpected cell layout.
  • OCR accuracy. OCR on scanned PDFs will contain some recognition errors, especially with poor scan quality. Always review the extracted data.

Tips for better results

  • If a PDF contains multiple table formats across different pages (for example, a summary table on page 1 and a detail table on pages 2-10), the schemas won't match, so they arrive as separate entries in the import picker. Load the one you want, or load both and clean each individually.
  • After extraction, use the pipeline to rename columns if the headers came through with extra whitespace or concatenated text. The Rename Columns operation handles this.
  • Numeric columns may extract as text if they contain currency symbols or commas. Convert Type to number strips that formatting for you, so you rarely need a separate cleanup step first.
  • For multi-page tables, the repeated page headers are detected and dropped while the pages are stacked, so you shouldn't need a Filter to clean them out. Do scan the first few rows anyway if the document has an unusual running header.

Limitations

The parser processes a maximum of 50 pages. For longer documents, split the PDF before loading it. Multi-page tables are detected page by page, but pages that share a column count and header text are stacked back into one table with the repeated headers removed, so a table spanning pages 3 through 7 arrives as a single dataset.

After extraction

Once the table is loaded, it behaves like any other dataset in ExploreMyData. You can filter, aggregate, join it with other files, add calculated columns, or export it. Common next steps:

  • Export as CSV for use in other tools: PDF to CSV
  • Then format that CSV as Excel if you need to share it: CSV to Excel
  • Build a pipeline to clean and transform the extracted data before exporting

Extract a PDF table now →

AA

Arif Aslam

Staff engineer in Bangalore. By day at Mammoth Analytics; building ExploreMyData on the side. More on my author page or LinkedIn.

Try it yourself

No sign-up, no upload, no tracking.

Open ExploreMyData