Live data from Hacker News

Diff-pdf: tool to visually compare two PDFs

github.com

21–30 of 85 posts

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

#22
post #8

Crazy, I'd have thought that modern multi-modal LLMs can do this, but when I tried Gemini, ChatGPT-4o and Claude they all pooped out: - Gemini at first only diff'd the text, and then when pushed it identified the items in the images and then hallucinated the differences between the versions. It could not produce an image output. - Claude only diff'd the text and refused to believe that there images in the PDFs. - Cha…

Visually comparing two PDFs is something a PC can do deterministically without any resource (and energy) intensive LLMs. People will soon use LLMs for things they are not especially good or efficient at, like computing the sum of numbers in an Excel table... (or are they doing it already?).

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

#23
post #8

Crazy, I'd have thought that modern multi-modal LLMs can do this, but when I tried Gemini, ChatGPT-4o and Claude they all pooped out: - Gemini at first only diff'd the text, and then when pushed it identified the items in the images and then hallucinated the differences between the versions. It could not produce an image output. - Claude only diff'd the text and refused to believe that there images in the PDFs. - Cha…

I would fully expect an LLM to not get natively good at this but to know how to reach out to another tool in order to get good at this

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

#24

I have been using this in a CI pipeline to maintain a business-critical PDF generation (healthcare) app (started circa 2010 I think), here is the RSpec helpers I'm using: https://gist.github.com/thbar/d1ce2afef68bf6089aeae8d9ddc05d... The code contains git-stored reference PDFs, and the test suite re-generate them and assert that nothing has changed. Helped a lot to audit visual changes, or PDF library upgrades!

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

Hashes can change regularly due to metadata. Source checks may also require some filtration or preprocessing before comparison. Visual comparison is the best option here, especially if you have a complex document with multiple third-party components that may change both the hash and source but keep the visual appearance the same.

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

#25

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

From the github:

Another option is to compare the two files visually in a simple GUI, using the --view argument:

$ diff-pdf --view a.pdf b.pdf

This opens a window that lets you view the files' pages and zoom in on details. It is also possible to shift the two pages relatively to each other using Ctrl-arrows (Cmd-arrows on MacOS). This is useful for identifying translation-only differences.

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

#27
post #12
post #4

Interestingly, Github thinks the project is 46% shell, due to the fairly huge wxwin.m4.

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...

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

#28
post #26

Earlier quoted context omitted.

Here is one: https://vslavik.github.io/diff-pdf/

Can anyone explain how to interpret that screenshot? It just looks like a very blurry text to me.

It's showing you both PDFs overlaid on each other. The main window looks blurry because the main text has shifted vertically slightly. The regions that have changes are highlighted in the thumbnails on the left.

I agree it's not the best initial example to demonstrate the tool, but it does show how it can be used to detect even minor spacing changes.

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

#30

I have been using this in a CI pipeline to maintain a business-critical PDF generation (healthcare) app (started circa 2010 I think), here is the RSpec helpers I'm using: https://gist.github.com/thbar/d1ce2afef68bf6089aeae8d9ddc05d... The code contains git-stored reference PDFs, and the test suite re-generate them and assert that nothing has changed. Helped a lot to audit visual changes, or PDF library upgrades!

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

If the document is a legally required disclosure (like a bank's fee schedule for example) then you need to grade that document directly rather than its source code. PDFs are horrible and there is a lot that can go wrong with making them between writing and publishing.
Post reply on HN