Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare two pdf files through command line [closed]

Tags:

pdf

acrobat

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.

like image 217
Rpant Avatar asked Jun 12 '12 20:06

Rpant


People also ask

Can I compare two PDF documents for differences?

You can use the Compare Documents tool to find differences between two versions of PDF files. After comparing two files, Acrobat provides a detailed report of every change, including text, fonts, images, and even the order of the pages. Choose Tools > Compare Documents. Choose the documents to compare.

Can you compare 2 pdfs in PDF Xchange editor?

The Compare Documents feature is located in the Review tab: The Compare Documents dialog box will open. Select the documents you want to compare, and click OK: When the comparison is complete the Compare Result dialog box will open and display the results.

How can I look at 2 PDF files at the same time?

Open a pdf file and right-click any area in the tab > Select 'Split View'. Open a pdf file and click 'View' on the main menu > Select 'Split View'. Open the files in two tabs and click the area between the tabs.


2 Answers

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.

like image 74
Kurt Pfeifle Avatar answered Dec 17 '22 19:12

Kurt Pfeifle


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.

like image 40
gamma Avatar answered Dec 17 '22 19:12

gamma