The question how to create identical PDF files with pdflatex was basically answered in this question already:

How to create identical PDF files?

The catch was to filter out the entry /ID in the trailer dictionary after the PDF file was created.

I am now forced to use xelatex and there this trick does not work any more, because there are many more changes in the resulting PDF files.

Here is the minimal working example again:


If I now create 2 PDF files, convert them to a hex dump and view the differences...

xelatex mwe.tex; mv mwe.pdf a.pdf; xxd a.pdf > a.bin
xelatex mwe.tex; mv mwe.pdf b.pdf; xxd b.pdf > b.bin
diff -u a.bin b.bin 

... then you can see that there are many differences in the resulting PDF files unfortunately.

Is there any way to produce bitwise identical PDF files with xelatex?

The reason I need this is that I'd like to create PDF files for a software release package. Of course the software release package should be identical when the underlaying software and documentation has not been changed.

  • For which use case do you need that?
    – buhtz
    Commented Oct 3, 2016 at 7:39
  • 1
    I use a script to create a release from a software: it gets the software from a GIT server, then creates the documentation using xelatex, then puts all this together in a ZIP. If nothing has changed, the result should be bitwise identical. If the PDF documentation is handled under version control as well, then running the script changes the PDFs every time. GIT will then think that the PDF has changed, but they haven't. It's annoying.
    – VerTeX
    Commented Oct 5, 2016 at 10:06

1 Answer 1


with recent Texlive releases you can use


You may also want to set


the first setting is the epoch setting. That is, the number of seconds since 1970.

E.g., for today (rather than 0 which is the 1st Jan 1970) you could use 1505482364 as found by:

$ date +%s

The second if set to 1 (or anything) causes tex commands such as \year to use the specified epoch date rather than the system clock.

The combination of two of them produces reproducible results (after the second run) in texlive2017 using the supplied test file.

First run:



Package hyperref Warning: Rerun to get /PageLabels entry.

second run



Output written on pp407.pdf (1 page).
Transcript written on pp407.log.

save pdf

cp pp407.pdf pp407-a.pdf

run again

Output written on pp407.pdf (1 page).
Transcript written on pp407.log.


cmp pp407.pdf pp407-a.pdf

No output from cmp confirming that the files are identical.

  • 1
    I think SOURCE_DATE_EPOCH_TEX_PRIMITIVES has been renamed to FORCE_SOURCE_DATE. Commented Apr 3, 2019 at 20:42
  • I combine this trick with the use of latexmk to avoid unnecessary compilations.
    – projetmbc
    Commented Oct 1, 2023 at 19:32
  • Good to know. But with lualatex and with pdflatex I can produce reproducible PDFs only with internal settings. For xelatex i know only setting trailerid. There seems no counterpart to \pdfsuppressptexinfo=-1 in pdflatex and similarly in lualatex Commented Nov 27, 2023 at 16:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .