Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions sampledb/generate_qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

base = 'test'

pages = 1
cols = 3
rows = 10
lmar = 0.1875
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions sampledb/templates/qr_template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
\end{document}