diff options
-rwxr-xr-x | netzbon/generate-qr.sh | 40 | ||||
-rw-r--r-- | netzbon/qr.tex.j2 | 14 |
2 files changed, 54 insertions, 0 deletions
diff --git a/netzbon/generate-qr.sh b/netzbon/generate-qr.sh new file mode 100755 index 0000000..e5c01c6 --- /dev/null +++ b/netzbon/generate-qr.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# This script is in the public domain. +# +# Call with the JSON file (like test.json) with +# an array of merchants to generate letters for! +# +# You must export +# +# export BASE_URL=https://e.netzbon-basel.ch/ +# +# before running this script! +# + +set -eu +LENGTH=$(jq length < $1) +echo "Generating $LENGTH QR codes for ${BASE_URL}" +DOMAIN=$( echo "${BASE_URL}" | sed -e "s/https:\/\///" | sed -e "s/\/$//") +mkdir -p qre +mkdir -p tmp + +for n in $(seq 1 $LENGTH) +do + echo "Processing merchant $n" + INDEX=$(expr $n - 1 || true) + ID=$(jq -r .[$INDEX].id < $1) + + jq ".[$INDEX]" < $1 | jq '.domain="'"${DOMAIN}"'"' > "tmp/${ID}.json" + cd tmp + ../render.py "${ID}.json" < ../qr.tex.j2 > "${ID}.tex" + pdflatex "${ID}.tex" < /dev/null &> /dev/null || true + pdflatex "${ID}.tex" < /dev/null &> /dev/null || true + pdflatex "${ID}.tex" < /dev/null + mv "${ID}.pdf" ../qre/ + cd .. + + echo "Done with ${ID}" +done + +pdftk qre/*.pdf cat output qr.pdf +echo "Combined letters are in 'qr.pdf'" diff --git a/netzbon/qr.tex.j2 b/netzbon/qr.tex.j2 new file mode 100644 index 0000000..52db22e --- /dev/null +++ b/netzbon/qr.tex.j2 @@ -0,0 +1,14 @@ +\documentclass[a4paper]{minimal} +\usepackage[ + paperwidth=53mm, + paperheight=53mm, + total={53mm,53mm}]{geometry} +\usepackage[nolinks,final,forget]{qrcode} + +\begin{document} +\ \vskip-3mm +\begin{center} +\qrcode[hyperlink,level=M,height=45mm]{taler://pay-template/backend.{{data.domain}}/instances/{{data.id}}/default} +\end{center} +\vfill +\end{document} |