chrise chrise - 1 year ago 92
Linux Question

PDF compare on linux command line

I'm looking for a Linux command line tool to compare two PDF files and save the diffs to a PDF outfile. The tool should create diff-pdf's in a batch-process. The PDF files are construction plans, so pure text-compare doesn't work.

Something like:

<tool> file1.pdf file2.pdf -o diff-out.pdf

Most of the tools I found convert the PDFs to images and compare them, but only with a GUI.

Any other solution is also welcome.

Answer Source

Done in 2 lines with (the allmighty) imagemagick and pdftk:

compare -verbose -debug coder $PDF_1 $PDF_2 -compose src $OUT_FILE.tmp
pdftk $OUT_FILE.tmp background $PDF_1 output $OUT_FILE

The options -verbose and -debug are optional.

  • compare creates a PDF with the diff as red pixels.
  • pdftk merges the diff-pdf with background PDF_1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download