disparPDF/disparPDFc

This tool can be used via command line or as a GUI program.
disparPDFc is disparPDF run by another name (a symbolic link to it, or on Windows a copy), which is always in batch mode and needs no display.

GUI Basic Usage

Click the File #1 button to choose one PDF file and then the File #2 button to choose another (ideally very similar) PDF file, then click the Compare button to perform the comparison, and when that's finished, navigate through the pairs of differing pages using the View combobox or using the Previous and Next buttons. Alternatively, drag two files—either separately or together—and drop them onto disparPDF's view panels, then click the Compare button.

The Compare Button

When the Compare button is pressed, disparPDF does a high-speed scan of every pair of pages (~100 pairs of pages per second on the author's machine). To make the scan as fast as possible disparPDF does a very rough check of each pair of pages—so it is possible that it identifies some false positives (i.e., page pairs that are really the same). False positives are quite rare. (There are no false negatives—differences are never missed.)

When a pair is reported as differing and nothing on it can be highlighted, a banner is drawn across the top of the left page. It reads disparPDF: Page Sizes Differ when the two pages are different sizes—a difference with nowhere to mark it—and disparPDF: False Positive otherwise.

Words Comparison Mode

The default comparison mode in the window is Words (batch mode compares the appearance unless told otherwise), which does a smart text comparison word by word for each pair of pages. This mode is fairly liberal regarding whitespace and tries to ignore layout changes (within a page) insofar as possible. It also treats all hyphens (soft-hyphen, minus sign, etc.), the same, that is, as a plain hyphen. This mode is best for alphabetic languages like English.

Characters Comparison Mode

The Characters comparison mode does a smart text comparison character by character for each pair of pages. This mode is liberal regarding whitespace at the ends of lines and tries to ignore layout changes (within a page) insofar as possible. It also treats all hyphens (soft-hyphen, minus sign, etc.), the same, that is, as a plain hyphen. This mode is best for logographic languages like Chinese and Japanese.

Appearance Comparison Mode

The Appearance comparison mode can be used to detect changes in fonts, diagrams, or any other visual aspects. This mode is absolutely strict and compares each pair of pages pixel for pixel. By default this mode shows differences using highlighting just like the Words and Characters modes do. However, it is also possible to compare using composition modes which can be useful to detect very small and subtle differences that aren't immediately apparent.

Zoning

Zoning is an experimental feature designed to produce more accurate results (i.e., fewer false positives). Its main use is for pages that have tables or that mix alphabetic and logographic text, since these can cause the underlying Poppler PDF library to provide the page's words mixed up. Warning: using zoning for large complex pages (bigger than A4, multiple columns, tables) in Characters mode can be very slow. (The current focus for the zoning code is functionality not efficiency.) Furthermore, in some cases zoning can cause an increase in false positives—this can occur because the zoning code reorders the text that is fed to the sequence matcher and sometimes the reordering is wrong. Getting this right is non-trivial; changing the tolerances may help.

The Tolerance/R value is the maximum distance between text (i.e., word) rectangles for the rectangles to be placed in the same zone. Lower values create more zones; higher values create fewer zones. More zones are expensive to compute but can produce more accurate results; fewer zones may reduce false positives. The Tolerance/Y value is used for rounding y coordinates up to a multiple of this value. For example, if Tolerance/Y is 5 and a word at position (452,137) is followed by a superscript at (468,140), both will be treated as having a y coordinate of 140.

Page Ranges

By default disparPDF compares every pair of pages in the two PDFs (or as many pairs of pages as the number of pages in the shorter PDF). It is also possible to compare particular pages or page ranges. For example, if there are two versions of a PDF file, one with pages 1-12 and the other with pages 1-13 because of an extra page having been added as page 4, they can be compared by specifying two page ranges, 1-12 for the first and 1-3, 5-13 for the second. This will make disparPDF compare pages in the pairs (1, 1), (2, 2), (3, 3), (4, 5), (5, 6), and so on, to (12, 13).

Page Offset

The Offset pairs each page of the first PDF with the page that many pages further on in the second PDF (or further back, if the offset is negative), counting pages within the page ranges. For example, with an offset of 1 the pages are compared in the pairs (1, 2), (2, 3), and so on. This is useful when material added to one PDF shifts the pages of the other, so that, for example, everything after a certain point is a page later.

The small arrow buttons at the right of each PDF's page range show the previous or next page of that PDF beside the same page of the other, changing the offset by one. So when added material puts one PDF out of step, step it on to bring the pages that correspond back together, without editing the page ranges. The comparison is redone straight away, and the pair shown is shown whether or not it differs.

Pages already examined are remembered, so changing the offset, or comparing again, is quick.

Margins

It is possible to make disparPDF ignore anything that is above a specified top margin, below a specified bottom margin, left of a specified left margin, and right of a specified right margin. One or more of these margins can be specified by, first, checking the Exclude Margins checkbox, and second by setting any of the margins. Margins can be set by clicking on a page view or by using the margin spinboxes. Each can be up to half the page's width or height, less 10pt (of the first page of the file chosen last). When comparing inside a page box, the margins are measured from the box's edges, and can be up to half the smaller of the two files' boxes.

Page Boxes

A PDF page can have up to five boundaries (ISO 32000-2:2020, 14.11.2): the MediaBox, the physical medium; the CropBox, to which it is clipped when displayed or printed; the BleedBox, to which it is clipped in production; the TrimBox, the finished page after trimming; and the ArtBox, the page's meaningful content. In the Page Box dock, Page boundary chooses one of them, and only what is inside it is compared—crop marks, colour bars or bleed outside the trim box, say, are ignored. Whole page compares the pages as they are, and Restore Default goes back to it.

Clipped to says what the box is clipped to: the MediaBox, as the standard requires (the default); the MediaBox and CropBox, so that only what a viewer shows is compared; or Nothing (as written), so that all of the box is, even where it extends past the MediaBox.

A page without the chosen box uses its default: the CropBox for the BleedBox, TrimBox and ArtBox, the MediaBox for the CropBox. Text is judged character by character, so in a word that straddles the box's edge only the characters inside it count. The pages are lined up on the box's top left corner, so a page with bleed matches the same page trimmed. In the views, and in what is saved, each page is shown whole, the part outside the box dimmed and the box outlined in blue; nothing outside it is highlighted. In Appearance mode, the composing choices of Show compose page 2 over page 1 inside the boxes, where they are compared, shown on page 1's page. Boxes, like margins, are in default user space units: /UserUnit is not applied.

Changing the box or the clipping forgets the comparison: click Compare again. Warnings—a box missing, the two files' boxes in different places or of different sizes, a box past the CropBox or the MediaBox, or nothing left of it—go to the Log, and the status counts them; in batch mode they go to standard error and into the --xmlResult file, and leave the result code alone. In batch mode --box-clip without --box is ignored, with a warning. The choice is kept for next time, except when it came from --box or --box-clip and was not changed in the window.

Saving

Use the Save As button to pop up a Save dialog. This dialog lets you save a .pdf file with the highlighted changes, or individual image files (e.g., in .png or various other common image formats). The dialog supports saving the current or all left pages, right pages, or both pages.

The Options Dialog

This dialog is invoked by clicking the Options button. It has three tabs.

General has Show Tooltips in the Main Window, which turns off the tooltips of the main window's controls; Rule width, the thickness of the margin rules that indicate the vertical position of differences, which a width of 0 switches off; and Files to compare, choosing whether the Choose dialogs offer only files whose names end in .pdf or any file. (A name typed into the File #1 or File #2 box, or a file dropped on the window, is taken whatever it is called; on the command line, --any-extension allows any name.)

Highlighting has the base color, whether to use an outline or a fill or both, and the fill's opacity, and Combine Highlighting in Text Modes, which merges neighbouring text highlights into one.

Performance has the Square Size, used in Appearance mode comparisons—the smaller the size the more fine-grained the highlighting is, and the slower to compute—and the Cache Size, the memory in MB that rendered pages may use.

Dock Windows

The Controls, Actions, Margins, Page Box, Zoning, and Log views are in dock widgets—these can be dragged into other dock areas (in which case they will reshape themselves as necessary), or dragged to float free. The Margins, Page Box, Zoning, and Log views can also be closed; right click a dock area splitter and check their checkbox to open them again. These views may be shown tabbed: if there is enough space they can be dragged out of their tabs and all shown in full.

Command Line Usage

disparPDF can be run from a console in two ways: with the window, given the files to compare, and in batch mode for automating checks, without a window.

Given two files on the command line, disparPDF starts up and compares them straight away, in the mode last used in the window (Words at first) unless -a (--appearance), -c (--characters) or -w (--words) is given. With --batch, or run under the name disparPDFc, it compares them without a window and prints a result code instead; --interactive asks for the window back.

Run it with --help to see all the options. Here is the --help output:

Usage: disparPDF [OPTION]... [FILE1 [FILE2]]
  or:  disparPDF --batch [OPTION]... FILE1 FILE2
  or:  disparPDFc [OPTION]... FILE1 FILE2
Compare two PDF files and show their differences.

The files are optional and are normally chosen in the window.  With --batch,
they are compared without a window, and the result code (see below) is
printed.

Options:
  -a, --appearance       compare the appearance of the pages (the default in
                           batch mode)
  -c, --characters       compare the text character by character
  -w, --words            compare the text word by word (the default otherwise)
      --any-extension    accept files whose names do not end in .pdf
      --box=BOX          compare only what is inside the page box BOX: media,
                           crop, bleed, trim or art (none, the default,
                           compares whole pages)
      --box-clip=CLIP    clip that box to the media box (media, the default),
                           to the media and crop boxes (crop), or not at all
                           (none)
      --language=LANG    use the given translation language, e.g., en for
                           English, cz for Czech; English is used if there is
                           no translation
      --debug=2          write the text fed to the sequence matcher into
                           files in the temporary directory (e.g., page1-1.txt
                           and page1-2.txt) when highlighting
      --debug=3          as --debug=2, but also with the coordinates, in y, x
                           order
  -h, --help             display this help and exit
      --version          output version information and exit

Batch mode options:
  -b, --batch            compare without a window
      --interactive      show the window (the default, except as disparPDFc)
      --outType=0        print only the result code (the default)
      --outType=1        print the result code and a description
      --pages=N          compare N pages (default all)
      --startPage1=N     start at page N of FILE1
      --startPage2=N     start at page N of FILE2
      --pdfdiff=FILE     save the pages that differ, highlighted, to FILE
      --xmlResult=FILE   write the result, in XML, to FILE
      --key=KEY          record KEY in the XML result
      --settings=FILE    read settings (zoom, margins, tolerances, colors,
                           etc.) from FILE, in INI format, instead of using
                           the defaults
      --compareFonts     also compare the fonts the files use

Result codes, printed in batch mode and also the exit status (modulo 256):
   0  the files are the same
   1  the files differ
   2  the files have different numbers of pages
   3  a start page is beyond the end of its file
   4  a file has fewer pages than --pages asks for
   5  the same file was given twice
   6  the files use different fonts (with --compareFonts)
  -1  a command line error
  -3, -4  FILE1 or FILE2 cannot be read
  -5  a page cannot be read
  -6, -7  the --pdfdiff or --xmlResult file cannot be written

In the window, press F1 for the full documentation, and click About for the
copyright and license details.
A typical command line for automated checks is:
disparPDF -b --pdfdiff=file_diff.pdf --xmlResult=file_results.xml --key=opkey file1.pdf file2.pdf
or:
disparPDFc -b --pdfdiff=file_diff.pdf --xmlResult=file_results.xml --key=opkey file1.pdf file2.pdf
The result codes are those listed at the end of the --help output above.

The text reordering is done by the TextItems::columnZoneYxOrder() method in the textitem.cpp file: suggestions for improvement are welcome! (Note that when using --debug=3 coordinates are output in y, x order.)

disparPDF is a port to Qt 6, by Yuwsuke Kieda in 2026, of ConfrontaPDF, a fork by Luca Bellonda, begun in 2015, of DiffPDF, which was created and maintained by Mark Summerfield 2008-2013. Its source is at https://github.com/yuw/disparPDF. The source for the last release of Mark's open source version is available from: http://www.qtrac.eu/diffpdf-foss.html And Mark's commercial versions are available from: http://www.qtrac.eu/diffpdf.html

If you're specifically looking for a command line PDF comparison tool, e.g., for automated testing, by Mark Summerfield try: comparepdf.