commit 342f93dc9e0d917e1f05f5d365737494fbdeffd8
parent 244d029783ed05d66151abcc554a55aed82c1cc1
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 15 Apr 2024 11:58:49 +0200
qr code generator
Diffstat:
2 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/netzbon/generate-qr.sh 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
@@ -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}