Live data from Hacker News

Diff-pdf: tool to visually compare two PDFs

github.com

61–70 of 85 posts

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

#61
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…

What’s the best way to effectively make use of Claude 3.5 ? I signed up a few days ago for the api access. Besides console.anthropic.com , do you recommend any other tools that I can run locally to give it api key and use claude effectively ?

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

#62
post #43

Related - this might be helpful to someone. ImageMagick can do a visual PDF compare: magick compare -density "$DENSITY" -background white "$1[0]" "$2[0]" "$TMP" (density = 100, $1 and $2 are the filenames to compare, $TMP the output file) You need to do some work to support multiple pages, so I use this script: https://gist.github.com/mbafford/7e6f3bef20fc220f68e467589bb... This also uses `imgcat` to show the differe…

Next level, especially with the git attribute calls, well played. I'm still blown away how powerful imagemagick is after using it for a decade or two, what an inspiring piece of open source software.

imagemagick really is magical.-

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

#64
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…

What’s the best way to effectively make use of Claude 3.5 ? I signed up a few days ago for the api access. Besides console.anthropic.com , do you recommend any other tools that I can run locally to give it api key and use claude effectively ?

The web interface gives you access to the Artifacts feature where it can build SPAs and render them in the browser.

For terminal access I like using my own https://llm.datasette.io/ tool with the https://github.com/simonw/llm-claude-3 plugin

For Python library access I recommend checking out Claudette: https://www.answer.ai/posts/2024-06-21-claudette.html

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

#65

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?

the source sometimes changed for small internal reasons in the library generating the PDF (prawn). So just comparing the source would not give a clear cut answer. A visual comparison has helped quite nicely over time.

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

#66

Earlier quoted context omitted.

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.

In this case, we indeed have multiple components (although not third-party), and being able to refactor those without risk is quite nice.

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

#67
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…

[deleted]

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

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

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

#69

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?

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

#70

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?

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