Why does it mangle the tables in my PDF?
Mangled PDF tables: a PDF stores a table as pieces of text placed at spots on the page, plus lines, with nothing that says which row or column a piece belongs to; pulled out as text, the pieces come in the order the file wrote them, empty cells leave no trace, merged cells and tables that continue on the next page shift the rest, and the chatbot has to guess the grid back; send a screenshot of the table to a model that reads images, paste a CSV or Excel export, and check a few cells of the table it returns · Beginner · 5 min · format, rag · after Chunking: chunk size, overlap and boundaries in RAG
A chatbot mangles PDF tables because a PDF stores pieces of text at spots on the page, not rows and columns. Pulled out as text, the grid is gone and the model guesses it back. Screenshots and CSVs keep it.
1 Guess first
2 Look
A table in a PDF, and what a chatbot gets from it
1 / 6The page
Region Q1 Q2 North 120 135 South empty 110 West 87 94 a test PDF we made (illustrative table); positions as written in the file
A small table in a PDF, as you see it. South has no Q1 number: that cell is empty.
The file holds only text at spots. Pulled out as text, the empty cell leaves no trace, and 110 slides into the wrong column.
Many chat apps pull the text out of a PDF before the model sees it. The model then reads tokens, small chunks of text, with the grid gone. An empty cell leaves no trace, a merged cell appears once for several rows, and a table split over two pages gets a page number in its middle.
4 You are the model
You are the chatbot, asked to rebuild the table, and you get only what the app gives you. Three times, say what South scored in Q1.
Round 1 of 3. Text from the column-order file
Region North South West Q1 120 87 Q2 135 110 94
Rebuild the table: what did South score in Q1?
texts: pypdf output from our test PDFs; picture: the same table
You are the chatbot. Say what South scored in Q1.5 Check
Tables stay hard even when a model reads the page as an image. On OmniDocBench (2025), 981 real pages, a score of 100 means a perfect rebuilt table: the best tool reached 78.6 on English tables, GPT-4o 72.0. Merged cells pulled GPT-4o from 64.7 to 56.8.
Three habits help. Send a screenshot, a picture of just the table, to a model that reads images, so it sees the grid. If you have the source file, export the table to CSV or Excel and paste that. Ask for the table back first, and check three or four cells against the PDF before you trust a total.
8 Say it back
9 Mission · 5 min
Open a PDF with a table (a bank statement, a timetable, a report), select the table and copy its text. In Google AI Studio (free), pick Gemini 3.8 Flash, paste it and ask “Rebuild this as a table.” Check three cells against the PDF. Then, in a new chat, upload a screenshot of just the table with the same request. Which version got all three cells right?
Three quick ones
Drawn at random from this lesson's pool; different next time.
Done?
Get an email when new lessons come out
New lessons arrive in the weekly digest, only in a week that has one. You confirm by email first; unsubscribe in one click.
Go deeper
Sources
- Test PDF made for this lesson on 2026-10-24 (illustrative table, one page, Helvetica, 4 rows x 3 columns, South’s Q1 cell empty), written twice: column by column and row by row. Content stream: “Region” at x 72 y 700, “Q1” x 200 y 700, “Q2” x 280 y 700; North 120 135, South (empty) 110, West 87 94 at y 680, 660, 640; plus grid lines. Text extracted with pypdf 6.21.2 extract_text() on 2026-10-24: column-by-column file “Region\nNorth\nSouth\nWest\nQ1\n120\n87\nQ2\n135\n110\n94”; row-by-row file “Region Q1 Q2\nNorth 120 135\nSouth 110\nWest 87 94” (pdfminer.six 20260107 gave one piece per line for both)
- The rebuilt table with 110 under Q1 and the role’s screenshot are illustrative, not recorded model output
- Ouyang et al., “OmniDocBench: Benchmarking Diverse PDF Document Parsing with Comprehensive Annotations” (CVPR 2025; arXiv:2412.07626 v2, 2025-03-25, https://arxiv.org/abs/2412.07626, checked 2026-10-24): 981 pages, 428 table boxes; tables scored with TEDS (tree-edit-distance similarity, shown 0 to 100). Table 2, end-to-end Table TEDS, EN: MinerU 78.6, Mathpix 77.0, Qwen2-VL-72B 76.8, GPT4o 72.0, Marker 67.6. Table S1, end-to-end Table TEDS by table attribute, GPT4o: Merge Cell (+/-) 56.8/64.7, Rotate (+/-) 14.2/62.7; Qwen2-VL-72B Merge Cell 67.9/78.1
- aifree.dev catalog, google-gemini-developer-api-free-tier (verified 2026-10-12, live check 2026-10-24): Gemini API free tier and Google AI Studio, Flash models with image and file input
Published Oct 24, 2026 · updated Oct 24, 2026