Keeping Tables Intact When You Convert a PDF to Markdown
Use a converter that rebuilds each table from the positions of the words, and a PDF goes to Markdown with its tables in one piece. Then compare every table with the PDF. A PDF has no real table inside it. It stores each word or number at a position on the page, so the converter has to work out the rows and columns again.
When that works, you get a Markdown pipe table with a header row and one line per row. When it fails, a number can move to the wrong column or a row can drop out of the table. The result still looks tidy, so the fault is easy to miss.
How a converter rebuilds a PDF table
MarkPrep rebuilds tables on your own computer, inside the browser, with no upload. On each page it first collects the words that share a vertical position into one line. Then it splits each line wherever there is a wide gap, about one and a half times the text height. Each piece becomes a cell.
A table is a block of two or more lines that each split into at least two cells. The cells also have to line up, so that at least two column positions repeat from line to line. MarkPrep then places each cell in the column nearest to it and makes the block's first line the header row.
One clean-up option affects tables. "Normalise tables" pads every row so the pipes line up. If rows in one table have different numbers of cells, the Verify tab shows a warning. That warning is useful, but it can't tell whether a number sits in the right column.
Worked example: an income statement from an annual report
Here is a made-up page from an annual report. It has a title, a heading, one line of notes and a six-line income statement, with the numbers right-aligned in two year columns. On 12 October 2026 we built this page as a PDF and ran it through MarkPrep's PDF table code. This is the Markdown it produced:
# Annual report 2026
### Consolidated income statement
Figures in thousands of pounds. Negative figures are shown in brackets.
| | 2025 | 2026 |
| --- | --- | --- |
| Revenue | 12,480 | 14,215 |
| Cost of sales | (7,302) | (8,010) |
| Gross profit | 5,178 | 6,205 |
| Operating expenses | (3,940) | (4,388) |
| Operating profit | 1,238 | 1,817 |
Every number is in the right row and year. The bracketed losses keep their brackets, and the empty top-left cell stays empty. The larger title and heading became Markdown headings because they were set in bigger type than the body text.
This is the best case, with one header line, single-line labels and numbers of similar width. Real reports are often messier.
Layouts that break tables in complex PDF files
We built a second test page with three common problems. Its segment table has a heading across both year columns and one label that wraps onto a second line. A table of costs also carries on at the top of the next page. Here is the Markdown for both pages:
Segment results
Year ended 31 December
| Segment | 2025 | 2026 |
| --- | --- | --- |
| UK | 4,100 | 4,650 |
| Rest of Europe | 3,020 | 3,380 |
| Other markets, including | 1,210 | 1,405 |
licensing income Total 8,330 9,435
| Staff costs | 2,010 | | 2,240 | |
| --- | --- | --- | --- | --- |
| Rent | | 610 | | 640 |
- A heading over several columns. Markdown tables have no merged cells, so "Year ended 31 December" became a plain line above the table. The years still head their columns, but the link between the two lines is gone.
- A label on two lines. The second line, "licensing income", has only one cell, so it ended the table. The Total row after it was left on its own and joined the text as a sentence. On a real report, that is the line you would most want to keep.
- A table split across pages. Each page is read on its own, so page two started a new table. Its first data row became the header. Its numbers were right-aligned but had different widths, such as 2,010 and 610, so their left edges sat in different places. The converter places a cell by its left edge, so each year column split into two.
None of these faults set off the Verify warning, because every row in each table still had the same number of cells. Only a look at the numbers catches them.
The converter has no column detection. It takes each page in horizontal lines from the top, so a table next to a text column can pull in that column's lines. A scanned page is read by English-only local OCR, which returns plain lines with no rebuilt table.
How do you check and fix a converted table?
Every PDF to Markdown table needs this one-minute check, however clean it looks:
- Count the rows in the PDF table and in the Markdown table.
- Find the total or subtotal rows and confirm each one is inside the table.
- Pick three numbers at random and check each one sits under the right column heading.
- Look for rows with empty cells in a regular pattern, such as every second column. That pattern usually means a column was split in two.
- Check the first table on each page. If a table carries on from the page before, join the two parts and delete the extra header line.
Fixing the Markdown by hand is quick once you know where to look. Move the stray Total row back into the table and delete the empty columns. If the spanning heading matters, add it to the header cells by hand, for example as "2025 (year ended 31 December)".
If the table started life in a spreadsheet, convert the spreadsheet instead. MarkPrep's spreadsheet converter reads the cells directly, so there are no positions to guess. For a report written in Word, the Word to Markdown converter keeps the tables Word stored, cell by cell.
How to parse tables in a PDF for RAG and LLMs
When you extract a table from a PDF for an LLM, a Markdown pipe table keeps its structure in plain text. Each row holds its label and its numbers on one line, and the header row names each column. A language model can read that without guessing which number belongs to which year.
In a retrieval (RAG) pipeline, PDF to Markdown tables are split into chunks along with the rest of the text. So a table has to survive chunking as well as conversion. MarkPrep's chunk preview keeps a table together when it fits inside one chunk. A table larger than the chunk size is cut into pieces, usually between rows, and only the first piece carries the header row. Raise the chunk size so your largest table fits, up to the maximum of 2,000 tokens. Each chunk's JSONL record also stores its heading path and, for PDFs, its page number. A model can then see which statement a row came from.
The conversion is free and local. It runs in your browser, so draft results or management accounts stay on your computer while you check that the tables survive. Try your own report on the PDF converter page, then open the chunk preview to see where it splits. The token counter shows whether the whole report fits a model's context window.
Try it on your own file
Convert a document and watch the token counter. It's free, needs no account and uploads nothing.