# How to prevent different checksums for different typesets

If I consider a simple LaTeX document such as:

\documentclass[11pt]{article}
\begin{document}
Hello, World!
\end{document}


then if I typeset it multiple times I get a different checksum each time

$pdflatex test This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009) restricted \write18 enabled. entering extended mode ... Output written on test.pdf (1 page, 12592 bytes). Transcript written on test.log.$ cksum test.pdf
2770399004 12592 test.pdf
$pdflatex test This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009) restricted \write18 enabled. entering extended mode ... Output written on test.pdf (1 page, 12592 bytes). Transcript written on test.log.$ cksum test.pdf
1225641903 12592 test.pdf


The different checksum is due to three lines changing in the PDF file:

/CreationDate (D:20101115092454-05'00')
/ModDate (D:20101115092454-05'00')
...
/ID [<E52BBC1CEFDC95455342C233D35D790A> <E52BBC1CEFDC95455342C233D35D790A>] >>


This is also the case with more complicated LaTeX input. Is there a way to typeset LaTeX files that would avoid this issue, so that if typeset multiple times, the checksum of the PDF file stays the same?

• Could you do a checksum of the source instead? – Will Robertson Nov 15 '10 at 14:34
• It looks like you will have to suppress the embedding of the Creation Date and Modification Date into the PDF. Are you sure you want to do that? – Matthew Leingang Nov 15 '10 at 14:48
• @Matthew: I have had the same problem several times (not only with Latex but also with many other tools that generate PDF files). Is there a very good reason to have those two timestamps embedded in the PDF file? Do the PDF standards require them? Is there a PDF viewer that actually uses those fields for something useful? – Jukka Suomela Nov 15 '10 at 15:06
• @Jukka: I believe search engines look at file metadata so it's good for that to be in there. But maybe there's a package/pdflatex patch that will avoid it. – Matthew Leingang Nov 15 '10 at 15:15
• Oh, it seems that this was answered at superuser.com: superuser.com/questions/130347/… – Jukka Suomela Nov 15 '10 at 15:32

I think that it is worth repeating the answer here. (Since this a is an exact copy from superuser, I should not get any rep for it...so I'm marking it CW):

You can change the contents of the pdf's Info dictionary using pdftex's \pdfinfo macro:

\def\fixedpdfdate{D:20100413000000+00’00’}
\pdfinfo{
/CreationDate (\fixedpdfdate)
/ModDate (\fixedpdfdate) }


Put this right at the beginning of the document: there's some risk that the dictionary gets written out in several chunks.

• Just to note that, \pdfinfo is not a macro but rather a primitive that is only available in pdftex and derived engines (i.e. luatex, but not xetex). – Khaled Hosny Nov 15 '10 at 17:01
• Thanks! Any idea how to prevent the same from happening with the \ID line at the bottom of the PDF files? – astrofrog Nov 15 '10 at 21:15
• @astrofrog: I thought that /ID was a checksum: obviously not. It looks like PDF readers don't mind you mutating the value of this object, so that the PDF between /ID and startxref reads: /ID [<0> <0>] >> startxref - I'd be interested to hear if any PDF readers are bothered about this. It may be the case that there is a cleaner way to nail down this value, though I'm guessing that Pdftex doesn't give you control over this. – Charles Stewart Nov 16 '10 at 9:59
• For luatex the primitive has to be activated before it can be used: \protected\def\pdfinfo {\pdfextension info } – Florian Apr 26 '18 at 19:13