## Sunday, January 31, 2016

### Reproducible PDFs from LaTeX

I like using version control, such as git, to store project files. When working with others it is often convenient to commit generated files, such as PDFs from LyX files. PDFs, however, may be different for inconsequential reasons, making them more inconvenient with version control systems.

I have patched the pdftex executables from MiKTeX so that if you are on Windows (x64), the PDFs can be identical. It removes the creation date, modification date, and trailer ID so that the PDF file is constant across runs. It also removes the filepath for included graphics so that if the file is made somewhere else (e.g. an a collaborator's machine) then they will still be identical (assuming they are built using the same LaTeX setup; would be nice to improve this). No changes are needed for you lyx/tex files.

To install:

1. Backup your current pdftex executables (in C:\Program Files (x86)\MiKTeX 2.9\miktex\bin): MiKTeX209-pdftex.dllmiktex-pdftex.exe, and pdftex.exe.
2.  Download this zip file and unpack the new versions of those three files into the above directory.
3. Be careful of updating the MiKTeX executables (though packages are fine).
I patched the version of pdftex that came with MiKTeX 2.9 (2015-08-24). It was primarily cobbled together from existing changes to the pdftex source code (svn access). See the diffs when changing revisions 222->223, 723->724, and 727->728. Hopefully, these changes will eventually be mainlined into the LaTeX distributions.