News for hackers. Stuff that matters.
Re:Show HN: PDF-Diff - Visualize any differences between two... by rcfox on Saturday August 06, 2022 @08:35AM (#32367532)
I made a PDF diff tool for myself for one of my internships >10 years ago.

One of my responsibilities was to get sign-off on any changes engineers made to schematics. (It was a really bad internship! I ended up automating a bunch of stuff for them because my actual job was mind-numbingly boring.)

After the first few times comparing PDFs of schematics by eye, I said screw it and wrote a tool to export to PNGs and then compare them pixel-by-pixel. It saved me a ton of time and my sanity.

Re:Show HN: PDF-Diff - Visualize any differences between two... by bob1029 on Saturday August 06, 2022 @09:46AM (#32368034)
Rasterization prior to comparison is a really clever idea. Doing this with PDF spec code would be an absolute nightmare. Checking 2 bitmaps for equality is just a few lines of code.

Many times, you aren't really concerned with the specific differences being described natively. You just want to know if a human would perceive differences between 2 copies of the "same" form.

Re:Show HN: PDF-Diff - Visualize any differences between two... by markrages on Saturday August 06, 2022 @04:00PM (#32371074)
I wrote a tool to do this for circuit board artwork changes. It used gerbv to rasterize the vector (gerber) files, then used XOR on the pixels to make unchanged areas disappear. For such a simple tool it is quite useful.
Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @08:37AM (#32367544)
> After the first few times comparing PDFs of schematics by eye, I said screw it and wrote a tool to export to PNGs and then compare them pixel-by-pixel. It saved me a ton of time and my sanity.

It saved mine! I usually work with books and sometimes it's really difficult to tell 10 people to check every single page if something has been different to a previous pdf I sent. They will never be able to find all the differences because we're humans, not bot. We make mistakes.

Re:Show HN: PDF-Diff - Visualize any differences between two... by btown on Saturday August 06, 2022 @10:41AM (#32368512)
https://draftable.com is my go-to tool in this space. It understands text flow and the difference between structural and formatting differences, and is amazing when given PDFs of legal docs that you need to retroactively get a redline for. Incredible tool, free but not open source.
Re:Show HN: PDF-Diff - Visualize any differences between two... by pea on Saturday August 06, 2022 @02:48PM (#32370563)
Nice work! We had to solve this problem a few years ago and iterated through a bunch of technical solutions and rabbit holes.

Funnily enough, the best performing solution for users was having the two PDFs rendered as images with a slider to "switch" between them, and relying on the human eye to spot the differences.

Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @02:51PM (#32370584)
Thank you! :) you do not know how many issues I spotted on older books I formatted. Paragraphes randomly moved on the top, images streched as I was build more pdf.. all human errors that can be - at least - spotted.
Re:Show HN: PDF-Diff - Visualize any differences between two... by elmimmo on Sunday August 07, 2022 @01:33AM (#32374148)
Kasyan Servetsky created a script[1] to compare two documents using a similar technique within InDesign, no intermediate export necessary. It overlays one on top of the other using the Difference blend mode. Quite resource intensive, so only useful depending on the particular document and machine you do this with.

[1]: http://kasyan.ho.ua/indesign/all/compare_two_documents.html

Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Sunday August 07, 2022 @04:03AM (#32374768)
Really similar to one I have already seen on Photoshop. My goal was comparing the pdfs without any Adobe, my editors do not have license for that.
Re:Show HN: PDF-Diff - Visualize any differences between two... by JakeAl on Saturday August 06, 2022 @02:30PM (#32370447)
I just use Beyond Compare from Scooter Software. Best program ever. Been using it for 20 years now. I swear by it as an evangelist user.

Diff images, Excel documents, PDFs, whatever.

Re:Show HN: PDF-Diff - Visualize any differences between two... by mandeepj on Saturday August 06, 2022 @07:51PM (#32372632)
> Diff images, Excel documents, PDF

I'm also a big fan and user of Beyond Compare, but I had no idea that it can also compare those files. The above file options are also not there in the app, especially I was looking for pdf.

Re:Show HN: PDF-Diff - Visualize any differences between two... by svat on Saturday August 06, 2022 @10:46AM (#32368549)
See also diff-pdf https://vslavik.github.io/diff-pdf/ that I usually use for this. (Seems to be relatively popular; 1.4k stars on GitHub: https://github.com/vslavik/diff-pdf)
Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @10:51AM (#32368618)
I took inspiration from that repository too! :)
Re:Show HN: PDF-Diff - Visualize any differences between two... by christkv on Saturday August 06, 2022 @03:31PM (#32370865)
Would stitching all the images together into a single continuous image before comparison be better? I mean you would trade off memory but would you not avoid page break errors?
Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @03:34PM (#32370884)
Probably. It's really similar to the approach that munificentbob used in his tool (http://journal.stuffwithstuff.com/2021/07/29/640-pages-in-15...). It uses mainly a Photoshop action.
Re:Show HN: PDF-Diff - Visualize any differences between two... by christkv on Saturday August 06, 2022 @03:39PM (#32370924)
This approach would be pretty cool for a bunch of file formats as long as you can rasterize them
Re:Show HN: PDF-Diff - Visualize any differences between two... by smartmic on Saturday August 06, 2022 @09:19AM (#32367823)
On Windows I was quite happy with DiffPDF[1]. As far as I remember there used to be an older open source version as well. But I could not found it on first glance.

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

Re:Show HN: PDF-Diff - Visualize any differences between two... by kondyt on Saturday August 06, 2022 @12:30PM (#32369493)
Re:Show HN: PDF-Diff - Visualize any differences between two... by niedzielski on Saturday August 06, 2022 @12:49PM (#32369629)
diffpdf doesn't look very pretty but it sure is useful. I use it for all my legal paperwork. Glad OP is contributing to this space.

https://screenshots.debian.net/package/diffpdf

Re:Show HN: PDF-Diff - Visualize any differences between two... by ajot on Saturday August 06, 2022 @02:02PM (#32370221)
This reminds me of this: https://news.ycombinator.com/item?id=28191343

Substracting PDFs with ImageMagick to test if a change in code produces the same output PDFs

Re:Show HN: PDF-Diff - Visualize any differences between two... by dloss on Saturday August 06, 2022 @09:33AM (#32367944)
i-net PDFC is my favorite tool in this space (after having tried a dozen others). Awesome features, multi-platform. Free trial version and an online demo available. https://www.inetsoftware.de/products/pdf-content-comparer

Not affiliated in any way, just a happy user.

Re:Show HN: PDF-Diff - Visualize any differences between two... by dloss on Saturday August 06, 2022 @09:43AM (#32368012)
And none of the other tools I've tried was significantly better than the old GPL-licensed version of DiffPDF: http://www.qtrac.eu/diffpdf-foss.html
Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @09:41AM (#32368001)
Thanks for the comment! I think it's not too difficult to build something similar (even with a web server so you can make comparison on fly).

I'm playing with alpha compositing, I'm going to commit some little changes to enchant the experience a little bit.

Re:Show HN: PDF-Diff - Visualize any differences between two... by dloss on Saturday August 06, 2022 @09:54AM (#32368098)
Most important for me is the ability to ignore page boundaries. Removing the first half of the first page of one source document shouldn't produce differences on all following pages.
Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @10:00AM (#32368158)
Thanks for the feedback. Should the user specify the page boundaries or does pdf-diff automatically checks where page boundaries are?
Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @01:10PM (#32369787)
> It's automatic. As if there were no page boundaries, like in text diffs). But for a paged-based diff-tool it would already be quite useful, if the user could interactively specify pages to ignore, so that the comparison can start again where both docs are the same (e.g. at the start of the next chapter).

Gotcha. I might transform this project from a command-line only to a visual tool. I could implement that, thanks for the idea. I can actually have some sections of the PDF ignored.

Re:Show HN: PDF-Diff - Visualize any differences between two... by dloss on Saturday August 06, 2022 @01:06PM (#32369757)
It's automatic. As if there were no page boundaries, like in text diffs). But for a paged-based diff-tool it would already be quite useful, if the user could interactively specify pages to ignore, so that the comparison can start again where both docs are the same (e.g. at the start of the next chapter).
Re:Show HN: PDF-Diff - Visualize any differences between two... by phonon on Saturday August 06, 2022 @02:02PM (#32370227)
https://www.parepdf.com/ is pretty nice.
Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @02:26PM (#32370416)
It looks like I need to watch it with 3d glasses, but I like it!
Re:Show HN: PDF-Diff - Visualize any differences between two... by iamandras on Saturday August 06, 2022 @04:53AM (#32366287)
Did you try it with more complicated PDFs?
Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @05:03AM (#32366329)
Thanks for your comment! By complicated PDFs, what do you mean exactly? A lot of pages? With forms? I've tried with standard technical books I have bought.

The pdf-diff tool simply captures a sort of "screenshot" of a PDF page and then compares it against to the page from the second PDF file you'd like to compare. Since it works by comparing raw pixels, I guess it'll work with complicated PDFs.

Now "working" does not mean it's a good result for the eye and this is why I asked for help regarding some issues.

Re:Show HN: PDF-Diff - Visualize any differences between two... by mr_mitm on Saturday August 06, 2022 @09:03AM (#32367729)
ImageMagick's `compare` can do this as well, on a pixel-level.

The issue is that in some cases, for example when the change is that a long sentence has been inserted in the middle of the document, the following headline and some of the first paragraph of the following section move to the next page. Then everything that follows is just marked red and the diff becomes useless.

Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @09:05AM (#32367738)
> ImageMagick's `compare` can do this as well, on a pixel-level.

Yes, thanks for the comment. I wanted to build something with golang :)

Re:Show HN: PDF-Diff - Visualize any differences between two... by kzrdude on Saturday August 06, 2022 @09:00AM (#32367709)
Aha. If one paragraph is added on page 1, it might show a diff on every following page in the same chapter after that, if it causes things to shift?

It's not easy to decide when such a change needs review and when it doesn't

Re:Show HN: PDF-Diff - Visualize any differences between two... by crecker on Saturday August 06, 2022 @09:03AM (#32367728)
Yes, if it causes things to shift, the tool shows every page red. This tool is meant to be ran in the final phase of typesetting, the moment when you want to focus attention on details (e.g. spacing).
Re:Show HN: PDF-Diff - Visualize any differences between two... by avipars on Saturday August 06, 2022 @02:41PM (#32370520)
Do you compare via OCR?