Kunj1724/diary-genration
0
CanTRAC Diary QR Generator
Generates a CanTRAC diary PDF with QR codes stamped on it. You enter a patient code (e.g. CanTRAC-A001 or just A001); the first letter picks the diary:
The QR encodes the full code (e.g. CanTRAC-A001) and is placed:
- in the top-right corner of every content page, with the code printed under it;
- as a big centered QR on page 2 (the ribbon/logo page);
- as a big low-centered QR on the 3rd-from-last page of the post diary.
The cover page, the page-2 logo page, and the last two pages have no corner QR.
Contents
add_qr.py core generator (also a command-line tool)
server.py web app — type a code in the browser and download the PDF
requirements.txt Python dependencies
peri.pdf post.pdf chemo.pdf Radiation.pdf source diariesSetup (once)
cd CanTRAC-diary-generator
python3 -m pip install -r requirements.txt # add --break-system-packages on macOS if neededWeb app (recommended)
python3 server.py # http://localhost:8000
python3 server.py 8080 # custom portOpen the URL, type a code (A001 or CanTRAC-A001), and the matching diary downloads automatically. The form only accepts a first letter of A/B/C/D followed by a number; anything else is rejected. Press Ctrl+C to stop.
Note:server.pybinds to0.0.0.0, so others on your network can reach it athttp://<your-LAN-IP>:8000. Change the host to127.0.0.1inserver.pyto keep it private to this machine.
Command line
python3 add_qr.py CanTRAC-A001 # any code; letter picks the diary
python3 add_qr.py A001 # short form works too
python3 add_qr.py # uses the default (CanTRAC-A001)Output is written next to the script as e.g. peri_CanTRAC-A001_with_QR.pdf.
Tunable layout constants (top of add_qr.py)
QR_SIZE, MARGIN_TOP, MARGIN_RIGHT, CORNER_CAP_FONT, BIG_QR / BIG_QR_Y0 (page 2), END_QR / END_QR_Y0 (post end page).
