diff --git a/sampledb/generate_qr.py b/sampledb/generate_qr.py index bea05a4..1befd00 100644 --- a/sampledb/generate_qr.py +++ b/sampledb/generate_qr.py @@ -26,6 +26,7 @@ base = 'test' +pages = 1 cols = 3 rows = 10 lmar = 0.1875 @@ -60,15 +61,21 @@ options['gpath'] = base codes = [] -for i in range(rows): +for i in range(pages * rows * cols): uid = str(uuid.uuid4()) code = qrcode.make(uid) filename = uid + '.png' with open(os.path.join(base, filename), 'wb') as img: code.save(img, 'PNG') codes.append((filename, uid[:6])) -options['qrs'] = codes - +codes = [c for c in zip(codes[0::3], codes[1::3], codes[2::3])] +qrs = [] +for c1, c2, c3 in zip(codes[0::3], codes[1::3], codes[2::3]): + for i in range(3): + for c in [c1, c2, c3]: + qrs.append(c) + +options['qrs'] = qrs result = template.render(**options) os.makedirs(base, exist_ok=True) diff --git a/sampledb/templates/qr_template.tex b/sampledb/templates/qr_template.tex index 41268b0..d97f51c 100644 --- a/sampledb/templates/qr_template.tex +++ b/sampledb/templates/qr_template.tex @@ -22,10 +22,10 @@ \numberoflabels=1 \begin{document} \begin{labels} -\BLOCK{for qr, uid in qrs} - \hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr}}\hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr}}\hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr}}\hfill\\ - \captionof*{figure}{\hfill \VAR{uid} \hfill \VAR{uid} \hfill \VAR{uid} \hfill} +\BLOCK{for qr1, qr2, qr3 in qrs} + \hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr1[0]}}\hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr2[0]}}\hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr3[0]}}\hfill\\ + \captionof*{figure}{\hfill \VAR{qr1[1]} \hfill \VAR{qr2[1]} \hfill \VAR{qr3[1]} \hfill} \BLOCK{endfor} \end{labels} -\end{document} \ No newline at end of file +\end{document}