TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?
share|improve this question
See also: How to track changes between PDFs? – Martin Tapankov Nov 28 '11 at 8:11
Another tool to consider is <a href="antennahouse.com/antenna-house-regression-testing-system/…;. Its not free, but it does a good job. – user3165987 Jan 6 '14 at 15:55
up vote 34 down vote accepted

You can try pdfpagediff package:

\layerPages[<optional page numbers>]{<file1>}{<file2>}
share|improve this answer




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.

share|improve this answer
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 Nov 28 '11 at 11:41
Could you please include some information on diffpdf in your post for completeness (and in case the links die). – N.N. Nov 29 '11 at 19:22
@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 Jan 28 at 9:55
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 Jan 28 at 11:46
@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 Jan 28 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";
share|improve this answer
The comparison fails. Error: compare: image widths or heights differ XY.pdf' @ error/compare.c/CompareImageCommand/962`. I'm on Linux. – Keks Dose Jul 27 '12 at 9:54
@KeksDose: Looks like your two PDFs don't have the same size, but this is a requirement with this code. – Martin Scharrer Aug 8 '12 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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
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 Nov 28 '11 at 11:33
@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 Nov 28 '11 at 12:50
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 Nov 28 '11 at 14:43

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.