Purpose: to make a unique filename for a PDF, starting with a LaTeX file. The goal is to prevent anyone from guessing how to find alternate versions of the document in the same directory.
To set up:
-
Install Python 3,
pipfor Python 3, andpyvenv. -
Install whatever you need for LaTeX. Here we assume you are using Xelatex; if you use
pdflatexorlualatex, replacexelatexin the following line of code inadd_hash.py:subprocess.call(['xelatex', new_filename], stdout=subprocess.DEVNULL)
-
Create and populate a Python virtual environment (one-time step):
pyvenv v_env3 . v_env3/bin/activate pip install -Ur requirements.txt -
Activate virtual environment:
. v_env3/bin/activate python add_hash.py <path to .tex file>
The
.texfile should be in a subdirectory, specified in<path to .tex file>. The program will- calculate a hash value of the whole
.texfile - generate a PDF of the
.texfile usingxelatex - append the hash to the filename of the PDF and save it in the main directory
- leave the original
.texfile untouched in its subdirectory - delete all auxiliary tex files.
- calculate a hash value of the whole
-
If a PDF with the expected filename already exists, the program will exit and the files will be untouched.
-
Here is an example file: https://brannerchinese.com/resumes/resume_20150816_458973cad2d3d8aca53d0ea0932ef7bac82b728dfe2a32552c16dbbb2f197251.pdf
[end]