Sometimes I want to compare the results of two different settings to see which gives better results (e.g. during the final fine tuning before handing in a document). Such settings can result in small changes in the location of words and other elements of the document.


Seeing the documents side-by-side on screen is not always enough, and the cost of printing is too great.

  • Is there a method for overlaying two resulting PDFs (e.g. one PDF is transparent) so that the differences can be easily compared?
  • What other methods can one use to compare two PDFs?

9 Answers 9


You can try pdfpagediff package:

\layerPages[<optional page numbers>]{<file1>}{<file2>}




DiffPDF (free version)

The first link is a to a Latex package pdfpagediff, which, according to the author will

create a composite PDF by juxtaposing each page of file1.pdf over the corresponding page of file2.pdf or vice-versa. Since the PDFs are transparent, you can notice the slightest change visually by simply flipping through the pages

The other link is to a little windows program call DiffPDF, a PDF comparison tool that shows the differences in PDF files either textually or visually. You will also find it as a portable application at

PortableApps DiffPDF 2.1.3

As Florian mentions in his comment, you can download a Mac version from German CNET

UPDATE 28 Jan 2016

Since I wrote this answer, the DiffPDF you will find on the qtrac.eu's homepage (link in Florian's comment) is commercial software, very expensive and with a very restrictive license. The links in my answer are still valid and link to what probably is an older, free version of the software, or maybe a totally different software. I am not sure.

  • 5
    I'm a very happy user of diffpdf. The acutal developer's page is http://www.qtrac.eu/diffpdf.html where you also can find links to a precompiled Mac version.
    – Florian
    Commented Nov 28, 2011 at 11:41
  • 1
    Could you please include some information on diffpdf in your post for completeness (and in case the links die).
    – N.N.
    Commented Nov 29, 2011 at 19:22
  • 3
    @Florian The DiffPDF you link, has become an expensive, commercial software! The DiffPDF I link to, is free software. I suggest you either delete your comment.
    – Sveinung
    Commented Jan 28, 2016 at 9:55
  • 2
    That's unfortunately correct: Qtrac not only changed the licensing of the newer versions, they also removed the older ones -- which are still perfectly useable; the old page is archived here: qtrac.eu/diffpdf-foss.html I haven't tried the new commercial versions either and don't intend to with that price tag and license. Your diffpdf-link is indeed to the old version, unfortunately without a Mac-binary. But you can get the old Mac-binary from other places, e.g. cnet de.download.cnet.com/DiffPDF/3000-18497_4-75745980.htm
    – Florian
    Commented Jan 28, 2016 at 11:46
  • 1
    @Florian I am on Windows and use the portable version (2.1.3). Is it OK that I copy the link to the Mac-version into my answer?
    – Sveinung
    Commented Jan 28, 2016 at 15:52

I use the image comparison tool from Image Magick which is available under Linux and Windows (and also Mac, IIRC). It generates a raster image where everything identical is semi-transparent, but the differences are highlighted in red. One drawback is that you have to raster the PDFs and this has to be done page-wise. For example, to compare the first page of two PDFs you can use:

compare -metric PSNR -density 300 first.pdf[0] second.pdf[0] diff0.png

Where 0 stands for the first page (computers start to count at 0). Replace it with 1 for the second and with 2 for the third page, etc. The density is used for the vector to raster image conversion needed. Use higher values for a higher resolution, which takes more space and conversion time, of course. The optional -metric PSNR option also prints the difference as signal-to-noise ratio.

I wrote myself the following shell script comparepdfs which takes the two PDFs as two arguments and produces <number>diff.png files for all pages which show the differences.



if [[ -z "$OUTFILE" ]]; then


PAGESA=$(pdfinfo "$FILEA" | grep ^Pages: | sed 's/Pages:\s*//')
PAGESB=$(pdfinfo "$FILEB" | grep ^Pages: | sed 's/Pages:\s*//')

if [[ $PAGESA > $PAGESB ]];

for N in `seq 0 "$PAGES"`; do
    echo "Comparing page $N / $PAGES."
    compare -metric PSNR -density "$DENSITY" "$FILEA[$N]" "$FILEB[$N]" "${N}$OUTFILE";
  • 1
    The comparison fails. Error: compare: image widths or heights differ XY.pdf' @ error/compare.c/CompareImageCommand/962`. I'm on Linux.
    – Keks Dose
    Commented Jul 27, 2012 at 9:54
  • 1
    @KeksDose: Looks like your two PDFs don't have the same size, but this is a requirement with this code. Commented Aug 8, 2012 at 17:49

Imagemagick provides a compare utility to compare the differences between two image files. The compare-pdfs.sh script from the ConTeXt test suite splits the pdf into multiple pages and then uses imagemagick's compare to compare each page.


You can open the two pdf files as a layers of a single image in GIMP, and make the top layer semitransparent. You can also set the top layer to "subtract" or "difference" mode, so you will clearly see the differences between the two layers.


I've had a similar problem to the one in this thread. However, all the solutions proposed here were not suitable for my situation, since I wanted to compare (mostly) text changes.

Moreover, the changes were not "minimal", and the new document was several pages longer than the old one. For instance, I have not been able to make pdfpagediff work. As for the diffpdf tool, It seems that it can only compare PDFs with the same length, which made it unsuitable for my needs. I also didn't like the output produced when using the compare alternative.

Hence, my suggestion, if you have the LaTex sources, is to use the command latexdiff. It is quite simple, you just have to generate the differences between the .tex and .bbl sources. I've used the following Bash script:


if [[ $# -eq 0 ]]; then
    echo -e "\nUsage: $0 <old file> <new file> [-d | --debug]"
    echo -e "\n\tFile names must be specified without extensions, e.g.:"
    echo -e "\n\t\t'paper' instead of 'paper.tex' or 'paper.bib'"
    echo -e "\n\t-d | --debug do not deletes the generated temporary files.\n"
    exit 0


# Process old file sources
latex $old
bibtex $old
latex $old
latex $old

# Process new file sources
latex $new
bibtex $new
latex $new
latex $new

latexdiff "${old}.bbl" "${new}.bbl" > diff.bbl 
latexdiff "${old}.tex" "${new}.tex" > diff.tex

# Generate pdf
latex diff
latex diff
dvips -Ppdf -ta4 diff.dvi -o diff.ps 
ps2pdf diff.ps

# If debug, exit, otherwise, remove temporary files
if [[ $3 = "-d" || $3 = "--debug" ]]; then
    exit 0

rm diff.tex diff.bbl diff.aux diff.dvi diff.log diff.out diff.ps diff.spl

This is probably not the best tool for your particular use case, but the hint may be useful for other users who look for "Comparing the output of two PDFs" in a more general sense:

Adobe Acrobat Pro (unfortunately not the free Reader) provides a pretty good "Compare Documents..." feature, which produces a page-wise "diff PDF" out of two PDF documents. Acrobat does a great deal in not comparing pixels, but logical content (especially text), so that editorial changes are easy to detect.

I use this to check, for instance, if my students have incorporated the changes I asked them to do into the draft of their thesis.

  • 2
    While being accurate well presented, AA's comparison feature (at least vers. 9 on the Mac) is terribly slow, frequently crashes the application and has an absurd 250-pages limit. IMO nothing worth purchasing the software for.
    – Florian
    Commented Nov 28, 2011 at 11:33
  • 4
    @Florian: Thats true. It might be worthwhile to test the Windows version, though – given that on MacOS in general AA crashes a lot :-( In fact, I lost a lot of commenting and correction work by using AA on OSX; these days I use AA mostly from inside a Fusion VM, that is, under Windows. Ridiculously, this is not only more stable, but also a lot faster than using the native OSX version.
    – Daniel
    Commented Nov 28, 2011 at 12:50
  • 3
    My experience is that this Acrobat Pro feature is very good when the changes between documents are minor and local. So, tweaks to a figure or a typo fix that doesn't cause a change of line breaking/pagination that propagates beyond the initial paragraph are fine. A document-wide font change or a floating figure that moves to a different page will cause far too many changes, make the compare process extremely slow and produce so many differences that the result is almost useless. Good for checking tweaks from a coauthor, bad for checking journal-supplied proofs against your manuscript.
    – Lev Bishop
    Commented Nov 28, 2011 at 14:43

I used the online tool which does not require any additional installation: this They say they do not save your original code.


If you're comfortable using the terminal, you can use diff-pdf which has more functionality and is free:

$ brew install diff-pdf

then run

$ diff-pdf --output-diff=diff.pdf first.pdf second.pdf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .