← All posts

How we measure whether a Word file looks like the original PDF

"Looks fine" isn't a metric. Here's how we check, word by word and on documents the converter has never seen, how close the converted Word file is to its PDF.

Hernán Díaz Rodríguez··5 min read

You open a PDF in Word, accept the conversion warning and get something that looks like the original… until page two. The columns have merged into one, the table spans two pages and the footer sits in the middle of the text. To build a better converter I first needed an honest way to say how much better it is.

Video: a PDF report and the same report converted to Word, side by side.
On video (36 s, on YouTube): upload a PDF, convert it and compare it with the Word file you get.

Why it's hard

A PDF and a Word file store documents in opposite ways:

Converting one into the other means guessing the structure (this block is a justified paragraph, these are two columns, this is a four-row table) so that when Word lays it out again, every word ends up where it was. If the structure is even slightly off, the error carries forward: a line that breaks in a different place pushes every line after it.

The metric: words in place

"Looks fine" is deceptive: the eye forgives a lot on one page and nothing on the next. So the measurement is automatic and always the same:

  1. We convert the PDF to DOCX.
  2. We open the DOCX in Word (and in LibreOffice) and save it as a PDF again. That way we measure what the reader will see, not what we think we wrote.
  3. We extract the words from both PDFs, the original and the new one, with their positions.
  4. We pair the words by their text and order, page by page.
  5. For each pair we measure how far it moved: horizontally, the word's left edge; vertically, the baseline, because the bottom of the box depends on each font.

The score is the percentage of the original's words that appear on the same page and within 3 points of their place. Three points is just over a millimetre: less than the gap between two lines, so a line that jumps to the next one counts as a miss, but an invisible shift doesn't.

Example 1 Report Report 1.8 pt away: counts ✓ Example 2 Report Report 7 pt away: doesn't count ✗
In grey, the word in the original PDF; in black, the same word in the converted Word file. The circle is the 3-point tolerance around the reference point (left edge and baseline).

Measuring on documents it hasn't seen

It's easy to fool yourself: if you tune a converter while always looking at the same documents, it ends up working wonderfully on those and so-so on the rest. To avoid that, the documents are split into groups:

And one rule that's hard to keep: general fixes, not patches for a specific document. A patch raises the diagnostic score and doesn't show on the held-out set; a general fix raises both.

Results

With this method, on the 73 real held-out PDFs and opening the result in Word:

ConverterWords within 3 pt
Word opening the PDF1.4%
pdf2docx (open-source library)25.4%
Clic'n Done PDF94.7%

On the 148 sealed PDFs, which the converter had never seen, it scores 95.4%. The two numbers being so close is the best sign that we're not measuring a mirage.

We also tried Docling, an open-source AI that's very good at extracting a document's structure: it recovers the text well (around 94% on Word documents), but places 0% of the words within 3 points. That's not a flaw: it's designed so that another AI can read the document, not to reproduce how it looks. And it's why our converter relies on geometry and measured rules rather than a large model.

What still breaks

The metric also tells us where we're weakest, and that's worth saying:

The takeaway

The metric isn't perfect: a document can have every word in place and still miss a table rule. But it gives a reliable number you can follow change by change, and it forces you to be honest. Almost every improvement to the converter came out of the same loop: measure, look at the worst documents, find the general fix and measure again on the unseen ones.

If you'd like to see the result on your own documents, you can try the converter: it's free and files delete themselves within an hour.

Comments or ideas? Message me on LinkedIn. LinkedIn →