It is often interesting to know if the output of two different documents (or the same document using different package/kernel versions) is the same.
Which different techniques can be used to test this?
Just as an example document for testing:
xxxxxxxxxx
\documentclass{beamer}
\begin{document}
\begin{frame}
\vspace{0.1mm}% test with and without this line
abc def
\end{frame}
\end{document}
One possible approach is to make a visual diff of the resulting documents.
The following script is rather hacky and has a lot of external dependencies, but maybe it can be used as a starting point.
The main idea is that each page of the documents gets converted into a pixelate image and then the pixel values are compared. If they differ, they are highlighted in red.
Usage
It can be executed with
xxxxxxxxxx
lua pdfdiv.lua "document_old" "document_new"
and will produce an image diff-<page number-1>.png
for every page that has differences
Dependencies:
convert
andcompare
from theImageMagick
library- pdfinfo
- grep
- awk
- whatever I forgot in the list above
Disadvantages:
- slow (I really mean it, don’t try with a very long document)
Advantages:
- will not only show that something has changed, but provide visual context of what has changed. This way the user can for example judge if they mind that a word is 1 mm further down or not
- will sort out which pages actually do have changes, so no need to check all of them
Output from the test document:
Ulrike Fischer made me aware of the pdfpagediff
package
xxxxxxxxxx
\documentclass{article}
\usepackage{pdfpagediff}
\begin{document}
\layerPages{document.pdf}{document2.pdf}
\end{document}
This will produce a new document with the two previous ones overlayed. If you have adobe reader, you can use the layers
menu at the left hand site to toogle between the documents to see if there are any significant changes.
Caveats:
- If you have a document with opaque background (like beamer), you will only be able to see one layer at a time instead of both overlayed (but you will still be able to toggle between them)
- only works with pdfTeX