Syncing two PDFs isn't syncing two scrollbars

My first attempt was the one anyone would make: take the scroll position of the left pane, copy it into the right one, done. It worked for about ten minutes, which is to say until I tried it with two genuinely different documents.

The problem is that a scroll position isn’t a position in the document. It’s a measurement in pixels that depends on the zoom factor, the window height and the physical size of the pages. Two editions of the same book with different page formats have different total heights, so the same scroll percentage lands in two different places in the text. And the drift isn’t constant: it grows as you go down, which is the worst way a defect can behave, because at the start everything looks fine.

The fix is conceptual before it is technical. What the two panes exchange isn’t a scroll offset, it’s a position expressed in page units: page number plus the visible fraction of that page. Given that quantity, the receiving pane has nothing to interpret, it works out where that point falls with its own zoom and its own pages, and the two documents stay aligned even when one is typeset at 7 inches and the other at 10.

That left the most interesting case, which is also mine: the two editions don’t have the same number of pages. The English translation of my book runs about ten pages longer, scattered through, because some chapters stretched. Aligning page 40 with page 40 is right at the start of the book and wrong at the end.

Here I borrowed an idea from a tool I’ve used for twenty years, WinMerge, which for text files has sync points: you declare that this line on the left corresponds to that line on the right, and the comparison realigns from there on. Translated to PDFs: you declare that page 41 of document A corresponds to page 43 of document B, and from that point on the mapping accounts for the offset. Where one document has pages the other doesn’t, the pane shows a gap instead of sliding everything else out of place.

The part I enjoyed most was avoiding having to declare those points by hand. Almost every serious PDF has bookmarks, and bookmarks are already a map of the document. If chapter 3 exists in both files, that’s a sync point and the program can work it out on its own.

The catch is that the two documents are in different languages, so the titles never match by literal comparison. “Chapter 3” and “Capitolo 3” and “Fejezet 3” are the same place, and to notice that you have to recognise the prefix and keep the number. Today the recognition covers fourteen languages, and the same table also pairs up the sections that have no number at all: the table of contents is called “Contents”, “Indice” or “Tartalomjegyzék” depending on where you are, but it’s always the table of contents.

The upshot is that you open two editions, configure nothing, and the anchor points are already there. When they aren’t enough, you add your own with a keyboard shortcut, the way you would in a diff.

The lesson I took away is that synchronisation was never an interface problem. It was a document model problem: as long as the two panes were exchanging pixels, no clever shortcut was going to save them.


Last modified on 2026-07-20