10

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.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Rpant
  • 974
  • 2
  • 14
  • 37
  • What exactly should that command line result tell you? *'There are visual differences between the two files'* or *'Input files are not visually different.'* ?!? Or do you want a new PDF that highlights the differences which can be found?!) – Kurt Pfeifle Jun 12 '12 at 21:12
  • Are you looking for non-payware programs only, or are you also interested to know about payware applications? – Kurt Pfeifle Jun 12 '12 at 21:13

3 Answers3

5

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.

gamma
  • 1,902
  • 1
  • 20
  • 40
  • The software is great, but very expensive: 180€ per year! (considering that I use it once or twice per month) – yannis Nov 10 '18 at 18:13
  • Well. 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. – gamma Nov 11 '18 at 20:19
3

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.

Othrayte
  • 637
  • 6
  • 18
rolve
  • 10,083
  • 4
  • 55
  • 75
  • 1
    The information in not valid anymore: (1) comparepdf, wether command line or not, runs only on Windows, (2) it is not open source. – yannis Nov 10 '18 at 18:11
  • @yannis, the link seems to be out of date, the new link for the GPL cmdline tool is http://www.qtrac.plus.com/comparepdf.html, I have submitted an update, don't know if it'll be approved. – Othrayte Aug 20 '20 at 02:52
2

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

  1. ImageMagick's compare command
  2. the pdftk utility
  3. 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.

Community
  • 1
  • 1
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345