Live data from Hacker News

Diff-pdf: tool to visually compare two PDFs

github.com

71–80 of 85 posts

Re: Diff-pdf: tool to visually compare two PDFs

#71
post #58

This inspired me to have Claude 3.5 Sonnet knock out a quick web page prototype for me, using PDF.js to load and render the PDFs to canvas elements and then display visual diffs between their pages. Two prompts: Build a tool where I can drag and drop on two PDF files and it uses PDF.js to turn each of their pages into canvas elements and then displays those pages side by side with a third image that highlights any di…

How much additional work did you have to do to get it into this form? Thats impressive work using those prompts.

Almost no extra work at all. You can see the full transcript here: https://gist.github.com/simonw/9d7cbe02d448812f48070e7de13a5... - it really was just those two prompts, then I copied the result out into a document to test it.

I modified the HTML a tiny bit before publishing it - I set the font to Helvetica and added the note at the bottom of the page showing the prompt I used.

The whole project took less than 5 minutes - then another 10 to write it up.

Re: Diff-pdf: tool to visually compare two PDFs

#72

I like this tool better: https://www.qtrac.eu/diffpdf.html It shows the differences in the GUI side-by-side instead of overlayed.

There is also an open-source/free version of this [1], which I use regularly. You can install it, e.g., in Fedora, with the ‚diffpdf’ package. It is no longer maintained but works very well, has a nice GUI with a side-by-side view, drag&drop support, and both text and visual modes.

[1] https://www.qtrac.eu/diffpdf-foss.html

Re: Diff-pdf: tool to visually compare two PDFs

#73

In a previous job, I had to validate the output of an unreliable production publishing system, so I tested dozens of PDF comparison tools available at the time. The best I found was called Delta Walker. It was proprietary commercial Mac-only software, but reasonably inexpensive, accurate, and could handle long PDFs with lots of graphics well. I remember evaluating this diff-pdf tool and finding that it fell short in…

Wouldn’t exporting pages to images and using pixel diff accurately identify differences in PDF’s?

I guess it depends on the use case. Imagine adding an extra sentence in the second PDF, and this causes the paragraph to have 6 instead of 5 lines, and the next paragraph begins a line further down, and the last paragraph of that page ends up in the next page, etc...

Re: Diff-pdf: tool to visually compare two PDFs

#74
post #12

Earlier quoted context omitted.

I noticed this a while back with a private project of mine. The Github languages breakdown seems broken. Mine is a Python project with a handful of Jupyter notebooks but many many python files. The LOC must be 80% python files but Github sees the project as 50% Jupyter.

You can tweak/exclude with .gitattributes https://github.com/github-linguist/linguist/blob/master/docs...

I had no idea. Thanks for sharing.

Re: Diff-pdf: tool to visually compare two PDFs

#75

Earlier quoted context omitted.

Wouldn’t exporting pages to images and using pixel diff accurately identify differences in PDF’s?

I guess it depends on the use case. Imagine adding an extra sentence in the second PDF, and this causes the paragraph to have 6 instead of 5 lines, and the next paragraph begins a line further down, and the last paragraph of that page ends up in the next page, etc...

Thanks. That helped understand it better.

Re: Diff-pdf: tool to visually compare two PDFs

#76

In a previous job, I had to validate the output of an unreliable production publishing system, so I tested dozens of PDF comparison tools available at the time. The best I found was called Delta Walker. It was proprietary commercial Mac-only software, but reasonably inexpensive, accurate, and could handle long PDFs with lots of graphics well. I remember evaluating this diff-pdf tool and finding that it fell short in…

I found "Draftable" to be great

Re: Diff-pdf: tool to visually compare two PDFs

#77

Earlier quoted context omitted.

could you not just compare the source (or perhaps even the hash) of the PDF and assert on that?

What should I do when the assertion fails – inspect the PDF with my sad little caveman eyeball?

In my own tests where I inspect PDF differences in python, I iterate through the pages, if the number of pages is the same, I convert each of them with PIL to bitmap, get the diff (ImageChops.difference is black for everything same and colored for diffs) and find the content of the diff with `getbbox`. This gives me the coordinates of the rectangle where changes appeared, I then use those to also print the page with a colored rectangle and print out the crops.

I give out the original page, the original rectangle, the original page with colored rectangle, the new page and the new rectangle, the diff cropped and uncropped only after which I start using my caveman eyeballs

I also pixelate it a bit and have a brightness cutoff for the diff to see if the diff actually matters and i also try if re-cropping a bit so shifting by a limited amount of pixels makes it look like an ignorable difference because everything just moved to the left a bit but that is optional.

I also recommend exporting the new pdf from the CI/CD tool to be put back into the test as reference. Even between Linux distros and versions small changes in fonts and stuff like that make a difference

Re: Diff-pdf: tool to visually compare two PDFs

#79
post #71

Earlier quoted context omitted.

How much additional work did you have to do to get it into this form? Thats impressive work using those prompts.

Almost no extra work at all. You can see the full transcript here: https://gist.github.com/simonw/9d7cbe02d448812f48070e7de13a5... - it really was just those two prompts, then I copied the result out into a document to test it. I modified the HTML a tiny bit before publishing it - I set the font to Helvetica and added the note at the bottom of the page showing the prompt I used. The whole project took less than 5 min…

That's incredible.

Re: Diff-pdf: tool to visually compare two PDFs

#80
post #59

Earlier quoted context omitted.

What are BC features that you find to be so great? I'm genuinely curious - I heard of lot of BC being 'the tool' for diffing. I'm used to Meld, but my current employee has a pretty strict policy which tools could be used so at some point I've managed a licence for some older version of BC. But for some reason I've found its UI/the way it works a bit less optimal that I was accustomed for. Since I'm using that primari…

In comparison, Meld is not stable, nor fast, especially for big diffs. The UI is also more limited. Araxis Merge and WinMerge are good alternatives

Yea I found Araxis Merge better than BeyondCompare, FileMerge, DiffForm, and Meld (mostly based on diffing prose rather than code, though).
Post reply on HN