Skip to content
PDF Tool

PDF guides

Why PDF to Word breaks tables

By Felix Stiffel · · 6 min read

The table you see is not the table in the file

You convert a PDF to Word, open the result and find the table gone. The words are all there, but the columns have collapsed into lines of text, long cells have been chopped into several paragraphs, and the numbers no longer line up. It looks like the converter failed. Usually it did exactly what the file allowed.

A Word document stores a table as a table: rows, cells, and the text inside each cell. A PDF does not have to. In its simplest form, a PDF page is a list of drawing instructions: put these characters at this position in this font, draw a line from here to there. A table on a PDF page is often nothing more than a few hundred characters placed at the right coordinates and a set of thin lines drawn between them. The idea that these belong together as a grid exists only in the eye of the reader.

A converter therefore has to guess the table back from the positions. Some guesses are easy, others are impossible to get right every time.

Our test file

To see what happens in practice, we made a small order list in a word processor: one heading and a table with 4 columns (item, description, quantity, price) and 14 rows. That is a header row, 12 item rows and a total row in which the first three cells are merged. Every third item has a long description that wraps onto three lines inside its cell. We exported it to PDF with LibreOffice, the way many people produce PDFs every day.

The PDF page contains 457 characters and 20 straight lines, the borders of the table. That is everything a simple converter has to work with. LibreOffice also wrote a tagged PDF, which matters later: alongside the drawing instructions it stored a structure tree that marks 1 table, 14 table rows and 54 cells.

What PDF to Word produced

Our own PDF to Word tool turned the page into a document with 0 tables and 23 paragraphs, in 137 milliseconds. It works like many light converters: it reads the text and its position on the page, sorts it from top to bottom, and joins the pieces that sit on the same line into one paragraph.

For a simple row that works surprisingly well. The row for item A-101 became the paragraph "A-101 Hex bolt M8 2 6.50". The four cells are still in the right order, separated by single spaces. But nothing says where one cell ends and the next begins, so a description with spaces of its own, like "Hex bolt M8", runs straight into its neighbours.

The wrapped cells broke worst. The row for item A-100 turned into three paragraphs: "A-100 Steel bracket, 1 3.25", then "galvanised, for wall", then "mounting". The second and third lines of the description were treated as separate lines of text, because on the page they are separate lines. The 14 table rows became 22 paragraphs; the 23rd is the heading above the table.

The merged total row survived as "Total 253.50", which is readable, but the information that the total belongs in the price column is gone.

Why the guesswork fails

Three things make tables hard to recover from position alone.

Wrapped cells. On the page, the second line of a long cell is just a line of text slightly lower than the first. A converter that groups text by line, as ours does, starts a new paragraph for it. To keep the cell together it would have to know where the cell borders are, and borders are only drawings.

Columns without borders. Many tables use white space instead of lines. Then the only clue that two words belong to different columns is a wider gap. Whether a gap of 30 points is a column break or just generous spacing depends on the document.

Merged and empty cells. A merged cell spans several columns, an empty cell has no text at all. Both shift the remaining text, so a converter that counts columns from left to right puts values into the wrong column.

Our PDF to Excel tool goes one step further than PDF to Word: it looks for groups of text that start at similar horizontal positions and turns them into columns. On the test file it found all 4 columns, and every item number, quantity and price landed in the right column. But the wrapped descriptions still became extra rows, so the sheet had 23 rows instead of 15, and the quantities and prices arrived as text rather than numbers. A SUM over the price column needs them converted first.

When a converter can do better

The structure is not always lost. Two kinds of PDF give a converter more to work with.

Tagged PDFs carry a structure tree in addition to the drawing instructions. Our test file had one, with 1 table, 14 rows and 54 cells marked, exactly matching the original. A converter that reads tags can rebuild the table faithfully. LibreOffice wrote these tags in our test without any extra setting; other programs have a tagged or accessible PDF option in their export settings. Screen readers need the same information to read a table aloud. Our converters do not read tags yet; they work from text positions only.

Ruled tables can be reconstructed from their lines. As a check, we ran the test file through pdfplumber, an open-source Python library that detects tables from drawn lines. It found the one table with all 14 rows, and the three lines of each long description came back as one cell. If your table has visible borders on every cell, a line-based tool is worth trying.

Scanned PDFs are the hardest case: there is no text at all, only a picture. They need OCR first, and the table structure has to be guessed from the image.

How to rescue a table with less retyping

Ask for the source. If someone sent you a PDF of a spreadsheet, the original spreadsheet is always better. A short request often saves an hour of cleanup.

Use PDF to Excel for number tables. Even with the extra rows, it keeps columns apart, which is the hardest part to fix by hand. In the spreadsheet, delete or merge the continuation rows, then convert the number columns from text to numbers.

Use PDF to Word for running text, then rebuild the table in Word. If the rows came out as one paragraph each with the cells separated by spaces, Word can turn them back into a table, but only if every row has the same number of separators. Replace the spaces between cells with tabs first, then use Insert, Table, Convert Text to Table.

Copy one column at a time. For short tables, selecting text column by column in a PDF viewer that supports column selection is often faster than any conversion.

Export tagged PDFs yourself. When you are the one creating PDFs, turn on the tagged or accessible PDF option in your word processor. The file becomes better for screen readers and better for anyone who needs to get the table out again later.