How to compare two pdf files through command line
Solution 1
How about i-net PDFC - it does a full content comparison - text, images, lines, header/footer-detection and so on. You can use it either on command line or with a GUI (2.0, currently in public beta-phase).
The command-line tool already has the option to compare folders with PDFs against each other (or the extreme way: use the API ;))
Disclaimer: Yep, I work for the company who made this - so feedback highly appreciated.
Solution 2
Check out comparepdf:
comparepdf is a command line tool for comparing two PDF files. By default it compares their texts but it can also compare them visually (e.g., to detect changes in diagrams, images, fonts, and layout). It should prove useful for automated testing.
It is Open Source (GPL) and there are Windows binaries available.
Also:
If you want a GUI application that shows the detailed differences between PDFs use DiffPDF instead.
Solution 3
What you want simply cannot be done with Adobe Acrobat through the command line. However, you could do it with the help of some commandline utilities which you could unite into a shell or batch script.
1. Quick visual check for page image differences
One ingredient of this would be ImageMagick's convert
command, which you can test like this for two 1-page PDF files which have page contents similar to each other's:
convert -label '%f' -density '100' first.pdf second.pdf -scale '100%' miff:- \
| montage - -geometry +0+0 -tile 1x1 -background white miff:- \
| animate -delay '50' -dispose background -loop 0 -
This will open a window which switches with a delay of 50 dezi-seconds between displaying each of the two files, so it is easy to discover visual differences.
2. Script to generate PDF output visualizing differences between PDF files
I'm doing the same thing using a shell script on Linux that wraps
- ImageMagick's
compare
command - the
pdftk
utility - Ghostscript (optionally)
(It would be rather easy to port this to a .bat
Batch file for DOS/Windows.)
You can read details about this approach in this answer.
Rpant
Updated on June 04, 2022Comments
-
Rpant about 2 years
Does anyone know how to compare two pdf files using adobe acrobat through command line. I want to do this via command line because we want to compare hundreds of file every day through some automated windows tasks.
Any kind of help will be greatly. I do not want to limit myself to acrobat to compare , if there is something else available.
-
yannis over 5 yearsThe information in not valid anymore: (1) comparepdf, wether command line or not, runs only on Windows, (2) it is not open source.
-
yannis over 5 yearsThe software is great, but very expensive: 180€ per year! (considering that I use it once or twice per month)
-
gamma over 5 yearsWell. That’s up to the use case of course. We‘re now at v5 with many improvements over the years. You can always give the desktop app a free spin with every major release. And there is a Public Demo at our website that will probably suit your personal need.
-
Othrayte almost 4 years@yannis, the link seems to be out of date, the new link for the GPL cmdline tool is qtrac.plus.com/comparepdf.html, I have submitted an update, don't know if it'll be approved.