How to extract a table from a PDF
Tables in PDFs are frustrating. They look perfectly organised on the page, but when you copy them you get a jumble of numbers on separate lines, or every column run together.
The reason: a PDF doesn't store a table as rows and columns. It stores small pieces of text at exact positions on the page, plus some lines drawn around them. Your eye sees a grid; the file only knows "this text goes here". Getting a table out means rebuilding that grid.
Here are the options, from quickest to most thorough.
1. Find the original file first
Before fighting the PDF, check whether the data exists elsewhere:
- Bank statements, GST reports and invoices can usually be downloaded as Excel or CSV from the same portal.
- Reports made in Word or Excel: ask the sender for the original.
- Government and company data often has a CSV or XLSX version next to the PDF.
A spreadsheet converts to a clean table in seconds. Drop it on the Docuflat converter and each sheet becomes a Markdown table. See Excel to Markdown tables.
2. Copy and paste, then tidy
For a small table in a text-based PDF:
- Convert the PDF with Docuflat, or open it and copy the table.
- The rows usually come out one per line, with cells separated by spaces.
- Paste into a spreadsheet and use Data → Split text to columns (Google Sheets) or Data → Text to Columns (Excel), splitting on spaces or a fixed width.
- Fix the cells that split wrongly, usually ones that contain spaces themselves, such as names or addresses.
This takes a few minutes for a 20-row table and needs no special tools.
3. Use your spreadsheet's PDF import
Recent versions of Excel can import tables straight from a PDF (Data → Get Data → From File → From PDF, on Windows with Microsoft 365). It detects tables on each page and loads them as separate queries. It works well on cleanly laid-out tables and less well on tables without ruling lines.
4. Rebuild it as a Markdown table
If you need the table for documentation, a README or an AI chat, Markdown is often the easiest target:
| Item | Qty | Amount |
|-------------|----:|-------:|
| Licence | 1 | 9,999 |
| Support | 12 | 6,000 |
Convert the PDF, then add | between the cells of each row and a dashes row under the header. For a long table, it's quicker to fix it in a spreadsheet first (option 2), then save as CSV and convert that.
Scanned tables
If the PDF is a scan, there's no text to copy. Docuflat runs OCR on scanned pages and gives you the text line by line, which you can then split into columns as above. OCR on tables works best when:
- the scan is straight and at least 200 dpi;
- the table has clear gaps between columns;
- you choose the right OCR language, especially for numbers in Indian scripts.
Our guide to better OCR results has more tips.
Check the numbers
Whatever method you use, check the result against the original:
- Totals: add up a column and compare it with the PDF's total row.
- Row count: make sure no rows were skipped at page breaks.
- Decimal separators and minus signs:
1,234.50,(500)and500-can all mean different things.
Summary
Look for the original spreadsheet first. Otherwise convert the PDF, split the rows into columns in a spreadsheet, and check the totals. For documentation or AI use, finish with a Markdown table.