| 1 | <h2><font color="darkgreen">DiffPDF</font></h2> |
| 2 | |
| 3 | <ul> |
| 4 | <li><a href="#bas">Basic Usage</a></li> |
| 5 | <li><a href="#cmp">The Compare Button</a></li> |
| 6 | <li><a href="#txt">Words Comparison Mode</a></li> |
| 7 | <li><a href="#chr">Characters Comparison Mode</a></li> |
| 8 | <li><a href="#vis">Appearance Comparison Mode</a></li> |
| 9 | <li><a href="#zon">Zoning</a></li> |
| 10 | <li><a href="#ran">Page Ranges</a></li> |
| 11 | <li><a href="#mar">Margins</a></li> |
| 12 | <li><a href="#sav">Saving</a></li> |
| 13 | <li><a href="#opt">The Options Dialog</a></li> |
| 14 | <li><a href="#dock">Dock Windows</a></li> |
| 15 | <li><a href="#cli">Command Line Usage</a></li> |
| 16 | </ul> |
| 17 | |
| 18 | <h3 id="bas">Basic Usage</h3> |
| 19 | <p>Click the <b>File #1</b> button to choose one PDF file and then |
| 20 | the <b>File #2</b> button to choose another (ideally very similar) PDF |
| 21 | file, then click the <b>Compare</b> button to perform the comparison, |
| 22 | and when that's finished, navigate through the pairs of differing pages |
| 23 | using the <b>View</b> combobox or using the <b>Previous</b> and |
| 24 | <b>Next</b> buttons. Alternatively, drag two files—either |
| 25 | separately or together—and drop them onto <font |
| 26 | color="darkgreen">DiffPDF</font>'s view panels, then click the |
| 27 | <b>Compare</b> button. |
| 28 | |
| 29 | <h3 id="cmp">The Compare Button</h3> |
| 30 | <p>When the <b>Compare</b> button is pressed, <font |
| 31 | color="darkgreen">DiffPDF</font> does a high-speed scan of every pair of |
| 32 | pages (~100 pairs of pages per second on the author's machine). To make |
| 33 | the scan as fast as possible <font color="darkgreen">DiffPDF</font> does |
| 34 | a very rough check of each pair of pages—so it is possible that it |
| 35 | identifies some false positives (i.e., page pairs that are really the |
| 36 | same). False positives are quite rare. (There are no false |
| 37 | negatives—differences are never missed.) |
| 38 | |
| 39 | <h3 id="txt">Words Comparison Mode</h3> |
| 40 | <p>The default comparison mode is Words which does a smart text |
| 41 | comparison word by word for each pair of pages. This mode is |
| 42 | fairly liberal regarding |
| 43 | whitespace and tries to ignore layout changes (within a page) insofar |
| 44 | as possible. It also treats all hyphens (soft-hyphen, minus sign, etc.), |
| 45 | the same, that is, as a plain hyphen. |
| 46 | This mode is best for alphabetic languages like English. |
| 47 | |
| 48 | <h3 id="chr">Characters Comparison Mode</h3> |
| 49 | <p>The Characters comparison mode does a smart text |
| 50 | comparison character by character for each pair of pages. This mode is |
| 51 | liberal regarding whitespace at the ends of lines and tries to |
| 52 | ignore layout changes (within a page) insofar as possible. |
| 53 | It also treats all hyphens (soft-hyphen, minus sign, etc.), |
| 54 | the same, that is, as a plain hyphen. |
| 55 | This mode is best for logographic languages like Chinese and Japanese. |
| 56 | |
| 57 | <h3 id="vis">Appearance Comparison Mode</h3> |
| 58 | <p>The Appearance comparison mode |
| 59 | can be used to detect changes in fonts, diagrams, or any other visual |
| 60 | aspects. This mode is absolutely strict and compares each pair of |
| 61 | pages pixel |
| 62 | for pixel. By default this mode shows differences using highlighting |
| 63 | just like the Words and Characters modes do. However, it is also |
| 64 | possible to compare using |
| 65 | composition modes which can be useful to detect very small and subtle |
| 66 | differences that aren't immediately apparent. |
| 67 | |
| 68 | <h3 id="zon">Zoning</h3> |
| 69 | <p>Zoning is an experimental feature designed to produce more accurate |
| 70 | results (i.e., fewer false positives). Its main use is for pages that |
| 71 | have tables or that mix alphabetic and logographic text, since these can |
| 72 | cause the underlying popplar PDF library to provide the page's words |
| 73 | mixed up. <font color="red">Warning:</font> using zoning for large |
| 74 | complex pages (bigger than A4, multiple columns, tables) in Characters |
| 75 | mode can be very slow. (The current focus for the zoning code is |
| 76 | functionality not efficiency.) Furthermore, in some cases zoning can |
| 77 | cause an <i>increase</i> in false positives—this can occur because |
| 78 | the zoning code reorders the text that is fed to the sequence matcher |
| 79 | and sometimes the reordering is wrong. Getting this right is |
| 80 | non-trivial; changing the tolerances may help. |
| 81 | |
| 82 | <p>The Tolerance/R value is the maximum distance between text (i.e., word) |
| 83 | rectangles for the rectangles to be placed in the same zone. Lower |
| 84 | values create more zones; higher values create fewer zones. More |
| 85 | zones are expensive to compute but can produce more accurate |
| 86 | results; fewer zones may reduce false positives. The Tolerance/Y value |
| 87 | is is used for rounding <i>y</i> coordinates to the nearest multiple of |
| 88 | this value. For example, if Tolerance/Y is 5 |
| 89 | and a word at position (452,137) is followed by a superscript at |
| 90 | (468,140), both will be treated as having a <i>y</i> coordinate of 140. |
| 91 | |
| 92 | <h3 id="ran">Page Ranges</h3> |
| 93 | <p>By default <font color="darkgreen">DiffPDF</font> compares every pair |
| 94 | of pages in the two PDFs (or as many pairs of pages as the number of |
| 95 | pages in the shorter PDF). It is also possible to compare |
| 96 | particular pages or page ranges. For example, if there are two versions |
| 97 | of a PDF file, one with pages 1-12 and the other with pages 1-13 because |
| 98 | of an extra page having been added as page 4, they can be compared by |
| 99 | specifying two page ranges, 1-12 for the first and 1-3, 5-13 for the |
| 100 | second. This will make DiffPDF compare pages in the pairs (1, 1), (2, |
| 101 | 2), (3, 3), (4, 5), (5, 6), and so on, to (12, 13). |
| 102 | |
| 103 | <h3 id="mar">Margins</h3> |
| 104 | <p>It is possible to make <font color="darkgreen">DiffPDF</font> ignore |
| 105 | any text that is above a specified top margin, below a specified bottom |
| 106 | margin, left of a specified left margin, and right of a specified right |
| 107 | margin. One or more of these margins can be specified by, first, |
| 108 | checking the <b>Exclude Margins</b> checkbox, and second by setting |
| 109 | any of the margins. Margins can be set by clicking on a page view or by |
| 110 | using the margin spinboxes. |
| 111 | |
| 112 | <h3 id="sav">Saving</h3> |
| 113 | <p>Use the <b>Save As</b> button to pop up a Save dialog. This dialog |
| 114 | lets you save a <tt>.pdf</tt> file with the highlighted changes, or |
| 115 | individual image files (e.g., in <tt>.png</tt> or various other common |
| 116 | image formats). The dialog supports saving the current or all left |
| 117 | pages, right pages, or both pages. |
| 118 | |
| 119 | <h3 id="opt">The Options Dialog</h3> |
| 120 | <p>This dialog is invoked by clicking the <b>Options</b> button. |
| 121 | The dialog supports changing the highlighting color, whether to use |
| 122 | a pen or fill or both, and the fill's opacity. The Square Size is used |
| 123 | when doing Appearance mode comparisons: the smaller the size the more |
| 124 | fine-grained the highlighting is—and the slower to compute. |
| 125 | The Rule width determines the thickness of the margin rules which are |
| 126 | used to indicate the vertical position of differences; the rules can |
| 127 | be switched off using a Rule width of 0. |
| 128 | |
| 129 | <h3 id="dock">Dock Windows</h3> |
| 130 | <p>The Controls, Actions, Margins, Zoning, and Log views are in dock |
| 131 | widgets—these can be dragged into other dock areas (in which case |
| 132 | they will reshape themselves as necessary), or dragged to float free. |
| 133 | The Margins, Zoning, and Log views can also be closed; right click a |
| 134 | dock area splitter and check their checkbox to open them again. These |
| 135 | views may be shown tabbed: if there is enough space they can be dragged |
| 136 | out of their tabs and all shown in full. |
| 137 | |
| 138 | <h3 id="cli">Command Line Usage</h3> |
| 139 | <p>Although <font color="darkgreen">DiffPDF</font> is a GUI program, if run from a console with two PDF |
| 140 | files listed on the command line, |
| 141 | <font color="darkgreen">DiffPDF</font> will start up and |
| 142 | immediately compare them in Words mode, or in Appearance mode |
| 143 | if their names are preceded with <tt>-a</tt> or |
| 144 | <tt>--appearance</tt> on the command line, |
| 145 | or in Characters mode if their names are preceded with <tt>-c</tt> or |
| 146 | <tt>--character</tt> on the command line. Run |
| 147 | <font color="darkgreen">DiffPDF</font> with <tt>--help</tt> to see all |
| 148 | the command line options. (This won't work on Windows, although the |
| 149 | other command line options will.) Here is the <tt>--help</tt> |
| 150 | output: |
| 151 | <pre> |
| 152 | usage: diffpdf [options] [file1.pdf [file2.pdf]] |
| 153 | |
| 154 | A GUI program that compares two PDF files and shows |
| 155 | their differences. |
| 156 | |
| 157 | The files are optional and are normally set through |
| 158 | the user interface. |
| 159 | |
| 160 | options: |
| 161 | --help show this usage text and terminate (run the |
| 162 | program without this option and press F1 for |
| 163 | online help) |
| 164 | --appearance -a set the initial comparison mode to Appearance |
| 165 | --characters -c set the initial comparison mode to Characters |
| 166 | --words -w set the initial comparison mode to Words |
| 167 | --language=xx set the program to use the given translation |
| 168 | language, e.g., en for English, cz for Czech; |
| 169 | English will be used if there is no translation |
| 170 | available |
| 171 | --debug=2 write the text fed to the sequence matcher into |
| 172 | temporary files (e.g., /tmp/page1.txt etc.) |
| 173 | --debug=3 as --debug=2 but also includes coordinates in |
| 174 | y, x order |
| 175 | </pre> |
| 176 | |
| 177 | <p> |
| 178 | The text reordering is done by the |
| 179 | <tt>TextItems::columnZoneYxOrder()</tt> method in the |
| 180 | <tt>textitem.cpp</tt> file: suggestions for improvement are welcome! |
| 181 | (Note that when using <tt>--debug3</tt> coordinates are output in |
| 182 | <i>y</i>, <i>x</i> order.) |
| 183 | |
| 184 | <p>If you're specifically looking for a command line PDF comparison |
| 185 | tool, e.g., for automated testing, try |
| 186 | <a href="http://www.qtrac.eu/comparepdf.html">comparepdf</a>. |
| 187 |