WIP: final positioning for the tickets

Generate with:

python generate.py -n 24 --size 93 -m 20 -o eintrittskarten.pdf https://kara.d3q.de -g 12
This commit is contained in:
klemens committed 2025-02-01 01:44:45 +01:00
1 parent 2e001e5858
commit 64aa6b82ff
2 files changed
+56 -10

No files matched your search

+15 -9
View File
@@ -29,6 +29,7 @@ if __name__ == "__main__":
parser.add_argument("-o", "--output", type=str, help="Output file, defaults to 'qrcodes.pdf'.", default="qrcodes.pdf")
parser.add_argument("-s", "--size", type=int, help="Ticket height, defaults to 150.", default=150)
parser.add_argument("-m", "--margin", type=int, help="Margin (depends on printer), defaults to 0.", default=0)
parser.add_argument("-g", "--gap", type=int, help="Gap between tickets, defaults to 0.", default=0)
args = parser.parse_args()
@@ -53,16 +54,16 @@ if __name__ == "__main__":
used_usernames = set()
ticket_height = args.size
qr_code_size = ticket_height/2
qr_code_size = ticket_height/1.5
logo = svg2rlg("img/karaoke-outline.svg")
scaling_factor = ticket_height/logo.height
scaling_factor = ticket_height/logo.height/2
logo.scale(scaling_factor, scaling_factor)
logo_width = logo.width*scaling_factor
logo_height = logo.height*scaling_factor
ticket_width = logo_width + qr_code_size
codes_per_row = floor((page_width-args.margin*2)/ticket_width)
codes_per_col = floor((page_height-args.margin*2)/ticket_height)
codes_per_row = floor((page_width-args.margin*2)/(ticket_width+args.gap))
codes_per_col = floor((page_height-args.margin*2)/(ticket_height+args.gap/2))
if codes_per_col == 0 or codes_per_row == 0:
raise Exception(f"There is not enough space on A4 page to fit a QR code of size {ticket_width}x{ticket_height}!")
codes_per_page = codes_per_row*codes_per_col
@@ -79,15 +80,20 @@ if __name__ == "__main__":
code_width = bounds[2] - bounds[0]
code_height = bounds[3] - bounds[1]
current_x = args.margin+(ticket_width+args.gap)*x
current_y = args.margin+(ticket_height+args.gap/1.2)*y
drawing = Drawing(ticket_height, ticket_height, transform=[qr_code_size/code_width, 0, 0, qr_code_size/code_height, 0, 0])
drawing.add(qr_code)
renderPDF.draw(logo, pdf, args.margin+ticket_width*(x%codes_per_row), args.margin+ticket_height*(y%codes_per_col))
pdf.drawString(args.margin+ticket_width*(x%codes_per_row), args.margin+ticket_height*(y%codes_per_col), url)
renderPDF.draw(logo, pdf, current_x, current_y+35)
pdf.setFont("Helvetica", 12)
pdf.drawRightString(current_x+logo_width, current_y+16, "Hier anmelden →")
pdf.drawString(args.margin+ticket_width*(x%codes_per_row), args.margin+ticket_height*(y%codes_per_col)+logo_height, "Hier Code scannen")
pdf.drawString(args.margin+ticket_width*(x%codes_per_row), args.margin+ticket_height*(y%codes_per_col)+logo_height-10, "und Song anmelden!")
pdf.setFont("Helvetica", 8)
pdf.drawRightString(current_x+logo_width+qr_code_size-7, current_y, url)
renderPDF.draw(drawing, pdf, args.margin+ticket_width*(x%codes_per_row)+logo_width, args.margin+ticket_height*(y%codes_per_col))
renderPDF.draw(drawing, pdf, current_x+logo_width, current_y+5)
generated_codes += 1
if generated_codes >= args.number:
pdf.save()
+41 -1
View File
@@ -1,3 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg width="187.32608mm" height="264.97495mm" viewBox="0 0 187.32608 264.97495" version="1.1" id="svg1" xml:space="preserve" inkscape:version="1.4 (e7c3feb100, 2024-10-09)" sodipodi:docname="karaoke-outline.svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview id="namedview1" pagecolor="#505050" bordercolor="#eeeeee" borderopacity="1" inkscape:showpageshadow="0" inkscape:pageopacity="0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#505050" inkscape:document-units="mm" inkscape:zoom="0.76095324" inkscape:cx="448.12215" inkscape:cy="412.64033" inkscape:window-width="2560" inkscape:window-height="1416" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="layer1"/><defs id="defs1"/><g inkscape:label="Ebene 1" inkscape:groupmode="layer" id="layer1" transform="translate(-10.867715,-50.08543)"><path style="fill:#000000" d="m 105.37684,312.41827 c -1.45586,0 0.24069,-2.78377 0.33595,-2.95702 0.0953,-0.17324 0.14662,0.1809 0.11412,0.78699 -0.0325,0.60609 -0.0704,1.93675 -0.0841,2.95702 -0.0163,1.20429 -0.11337,1.85504 -0.27685,1.85504 -0.1808,0 1.8114,-2.64203 -0.0891,-2.64203 z m 2.49538,2.27158 c -0.86265,-0.54896 -0.39355,-3.69823 -0.0577,-5.81835 0.19542,-1.23376 0.42237,-3.81155 0.50434,-5.72842 0.082,-1.91688 0.18766,-4.14292 0.23486,-4.94678 0.34589,-5.89068 0.35009,-6.12112 0.10907,-5.97216 -0.3732,0.23065 -0.2962,-0.46703 0.0947,-0.85791 0.37974,-0.37974 0.64886,-2.74035 0.9068,-7.95403 0.11574,-2.33959 0.23481,-3.20416 0.44127,-3.20416 0.46534,0 1.34436,0.54162 1.36848,0.8432 0.0685,0.85662 0.10781,0.97113 0.29367,0.85626 0.11205,-0.0693 0.27226,0.37238 0.35602,0.98139 l 0.15229,1.1073 0.82446,-0.12645 c 0.45346,-0.0695 0.93913,-0.21617 1.07927,-0.32584 0.16255,-0.12719 0.30503,-0.0685 0.3935,0.16202 0.2519,0.65646 0.14722,0.77416 -0.70452,0.79209 -0.46376,0.01 -0.71609,0.069 -0.56073,0.13163 0.15536,0.0626 0.22527,0.20642 0.15537,0.31953 -0.0699,0.1131 0.28361,0.20565 0.78559,0.20565 0.74011,0 0.91268,0.0791 0.91268,0.41852 0,0.32771 0.1248,0.39467 0.57517,0.30858 0.37076,-0.0709 0.53309,-0.21963 0.45677,-0.41853 -0.0651,-0.16972 -0.0322,-0.30857 0.0732,-0.30857 0.10536,0 0.25562,0.22766 0.33392,0.50592 0.13507,0.48008 0.15827,0.48513 0.45434,0.099 0.19731,-0.25736 0.36614,-0.31935 0.45928,-0.16864 0.081,0.13107 0.0148,0.24542 -0.14705,0.25411 -0.16189,0.009 -0.092,0.096 0.15537,0.19406 0.3212,0.12731 0.4878,0.076 0.58303,-0.17943 0.2132,-0.57195 0.56744,0.28326 0.9694,2.34034 0.27589,1.41191 0.3282,2.86961 0.24816,6.91555 -0.0558,2.8196 -0.15352,5.21087 -0.21722,5.31392 -0.0637,0.10306 -0.12337,2.08223 -0.13261,4.39817 -0.0159,3.96975 -0.0418,4.21732 -0.45272,4.32478 -0.4945,0.12932 -0.59375,0.51125 -0.13285,0.51125 0.18372,0 0.31075,0.27023 0.32257,0.6862 0.0149,0.524 -0.07,0.67149 -0.35927,0.62396 -0.20833,-0.0342 -0.52062,0.0266 -0.69396,0.13514 -0.20965,0.13129 -0.40617,0.0729 -0.58693,-0.17425 -0.30307,-0.41449 -0.90219,-0.51945 -0.65172,-0.11418 0.10969,0.17748 -0.0244,0.22238 -0.43148,0.14455 -0.42633,-0.0815 -0.62466,-0.006 -0.71308,0.27301 -0.16526,0.5207 0.0891,1.12381 0.47391,1.12381 0.17227,0 0.31167,0.12648 0.30978,0.28107 -0.004,0.34865 -0.33441,0.88826 -0.52762,0.8624 -0.46597,-0.0624 -0.6199,0.0128 -0.53611,0.26186 0.0555,0.16512 0.36476,0.24889 0.74951,0.20312 l 0.65494,-0.0779 -0.54511,0.58386 c -0.54354,0.58218 -0.55565,0.58387 -4.19195,0.58387 -3.17932,0 -3.49714,-0.18473 -3.78898,-0.37045 z m 5.49052,-26.72437 c 0,-0.42639 -0.0914,-0.45822 0.50592,-0.36391 0.0928,0.0146 0.16864,-0.0746 0.16864,-0.19822 0,-0.12367 -0.0943,-0.22485 -0.20951,-0.22485 -0.11523,0 -0.1796,-0.27826 -0.14303,-0.61835 0.041,-0.38132 0.20141,-0.61945 0.41849,-0.62122 0.19361,-0.002 0.42662,-0.0775 0.51779,-0.16864 0.20525,-0.20524 -0.79697,-0.19037 -1.2583,0.0187 -0.1855,0.0841 -0.3422,0.40579 -0.34821,0.71497 -0.006,0.30917 -0.0838,0.84038 -0.17292,1.18047 -0.1395,0.5325 -0.0951,0.61835 0.31953,0.61835 0.40252,0 0.2016,0.0292 0.2016,-0.33728 z m 1.5741,-4.47278 c -0.48626,0.12157 0.0903,-0.78191 0.22485,-0.69876 0.12367,0.0764 0.22485,0.0255 0.22485,-0.11329 0,-0.13875 0.22656,-0.2206 0.50346,-0.18191 0.2769,0.0387 0.50457,-0.0308 0.50592,-0.15451 0.004,-0.36763 0.98645,-1.23881 1.1318,-1.00364 0.0736,0.11916 0.0827,0.29953 0.0201,0.40082 -0.0626,0.10129 0.19233,0.13924 0.56651,0.0843 0.4194,-0.0616 0.75731,-0.28311 0.88104,-0.57766 0.14878,-0.35418 0.18784,-0.18692 0.151,0.64645 l -0.0497,1.12427 -0.88973,-0.0791 c -0.83066,-0.0738 -0.86798,-0.0524 -0.56213,0.32317 0.29309,0.3599 0.28677,0.38698 -0.06,0.25708 -0.24335,-0.0912 -0.47458,-0.002 -0.62144,0.23897 -0.18747,0.30792 -0.20722,0.26582 -0.0995,-0.21211 0.12814,-0.5687 0.0945,-0.59468 -0.72768,-0.56213 -0.72284,0.0286 -0.86203,0.11254 -0.86203,0.51973 0,0.26708 -0.0759,0.5622 -0.16864,0.65582 -0.0928,0.0936 0.27836,-0.77925 -0.16864Line truncated
<svg
width="190mm"
height="80mm"
viewBox="0 0 190 80.000001"
version="1.1"
id="svg1"
xml:space="preserve"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
sodipodi:docname="karaoke-outline.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview1"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
inkscape:zoom="1.5219065"
inkscape:cx="332.80626"
inkscape:cy="224.38961"
inkscape:window-width="1280"
inkscape:window-height="907"
inkscape:window-x="2560"
inkscape:window-y="509"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" /><defs
id="defs1" /><g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-10.867715,-50.08543)"><path
style="fill:#000000"
d="m 89.074038,129.52476 c -6.015171,-0.43761 -10.209391,-4.82724 -10.77614,-11.27819 -0.162405,-1.84855 -0.14988,-2.35352 0.103243,-4.16244 0.468681,-3.34938 2.888343,-6.91124 5.83073,-8.58312 3.858205,-2.19226 9.481576,-2.37785 13.161737,-0.43438 1.283022,0.67756 2.698242,1.76825 2.698242,2.07951 0,0.21245 -2.010946,2.8823 -2.350473,3.12063 -0.477631,0.33527 -1.338726,0.15432 -2.413899,-0.50724 -2.827202,-1.73959 -6.712056,-1.32838 -8.883292,0.94031 -2.865109,2.9937 -2.763941,9.43446 0.192601,12.26186 1.203538,1.15096 2.52109,1.6323 4.48359,1.63797 1.942187,0.006 2.860353,-0.25323 4.114649,-1.15996 1.267366,-0.91617 1.855807,-0.83276 3.064944,0.43445 1.74106,1.82469 1.71003,1.69575 0.658583,2.73674 -2.405052,2.38114 -5.334956,3.24484 -9.884515,2.91386 z M 27.239391,116.62231 V 103.9181 h 1.784188 c 0.981304,0 2.027586,0.0925 2.325073,0.20565 0.299506,0.11387 2.07962,2.14584 3.988911,4.55328 1.896415,2.3912 4.374934,5.51125 5.50782,6.93344 1.132885,1.4222 2.297826,2.91466 2.588756,3.31659 0.29093,0.40192 0.585824,0.73082 0.655319,0.73087 0.0695,5e-5 0.09851,-3.54462 0.06448,-7.87705 l -0.06187,-7.87715 2.647686,0.0634 2.647685,0.0634 0.05809,12.648 0.05808,12.64799 h -2.138228 -2.138228 l -0.84295,-0.87906 c -0.463622,-0.48349 -3.321957,-4.00969 -6.351855,-7.83601 l -5.508904,-6.95695 -0.05909,7.83601 -0.05909,7.83601 h -2.582936 -2.582936 z m 25.294023,12.31072 c 0.08721,-0.21642 0.588723,-1.50652 1.114465,-2.86688 0.784153,-2.029 3.108118,-8.03528 7.656072,-19.78709 0.287161,-0.74201 0.588685,-1.57678 0.670055,-1.85504 0.143893,-0.49206 0.230309,-0.50592 3.155042,-0.50592 2.160759,0 3.057237,0.0791 3.18525,0.28107 0.147856,0.23327 3.603826,9.06081 6.140072,15.68352 0.355205,0.92752 1.310934,3.39517 2.123843,5.48367 0.812908,2.0885 1.478015,3.83392 1.478015,3.87872 0,0.0448 -1.24546,0.0814 -2.76769,0.0814 -1.931979,0 -2.88977,-0.0893 -3.171992,-0.29563 -0.222367,-0.1626 -0.785054,-1.4021 -1.250415,-2.75445 l -0.846111,-2.45882 -4.807386,-0.0532 -4.807387,-0.0532 -0.775534,2.37679 c -1.042926,3.19628 -1.102317,3.23843 -4.562898,3.23843 -2.474289,0 -2.67915,-0.0318 -2.533401,-0.39349 z m 16.072315,-9.33141 c -0.06365,-0.53706 -3.350355,-9.81869 -3.430123,-9.68665 -0.062,0.10263 -0.216234,0.54074 -0.342738,0.97359 -0.126504,0.43284 -0.845623,2.553 -1.598041,4.71147 -0.752419,2.15847 -1.368034,3.95449 -1.368034,3.99115 0,0.0367 1.51776,0.0666 3.372799,0.0666 1.855039,0 3.369801,-0.0253 3.366137,-0.0562 z m 34.858921,-2.97931 V 103.9181 h 2.89904 c 2.43611,0 2.92083,0.0568 3.03552,0.35567 0.0751,0.19562 0.13648,2.57345 0.13648,5.28406 v 4.92838 h 5.0592 5.0592 v -5.29058 -5.29058 l 2.9793,0.0627 2.97931,0.0627 0.0487,12.648 0.0487,12.64799 h -3.02797 -3.02796 v -5.28405 -5.28405 h -5.0592 -5.0592 v 5.28405 5.28405 h -3.03552 -3.03552 z m 32.37887,2.36096 v -10.34325 h -3.60552 -3.60551 l 0.0641,-2.30474 0.0641,-2.30475 10.06219,-0.0623 10.06218,-0.0623 v 2.36133 2.36133 l -3.54144,0.0619 -3.54144,0.0619 -0.0585,10.28704 -0.0585,10.28703 h -2.92082 -2.92083 z M 79.629677,97.659686 C 79.484041,97.611027 79.405348,93.174147 79.405348,85.01169 V 72.438645 h 5.242755 c 5.743668,0 7.220519,0.178009 9.254835,1.115511 2.594892,1.19584 3.772631,2.997297 3.901285,5.967366 0.06174,1.425375 -0.02198,2.064987 -0.403287,3.080857 -0.559703,1.49116 -2.065352,3.268673 -3.302592,3.898918 -0.475487,0.242211 -0.902522,0.461521 -0.948969,0.487355 -0.04645,0.02584 0.221576,0.304474 0.595604,0.619198 0.374028,0.314724 1.130836,1.305426 1.681796,2.20156 3.178055,5.169094 4.665115,7.648361 4.665455,7.778363 6.5e-4,0.255558 -6.154418,0.04193 -6.689737,-0.232184 -0.27824,-0.142475 -0.825091,-0.823762 -1.215225,-1.513971 -0.390134,-0.69021 -0.961066,-1.70494 -1.268737,-2.254955 -0.307672,-0.550016 -0.848548,-1.49042 -1.201948,-2.089788 -0.3534,-0.599368 -0.642545,-1.146634 -0.642545,-1.216147 0,-0.06951 -0.312055,-0.520388 -0.693454,-1.001945 -0.637358,-0.80473 -0.782872,-0.875557 -1.798826,-0.875557 h -1.105372 v 4.609492 c 0,4.23699 -0.0318,4.61015 -0.393494,4.617631 -4.163535,0.08612 -5.265522,0.09205 -5.453215,0.02934 z M 89.861024,83.688704 c 1.249563,-0.600784 1.567646,-0.903869 1.871822,-1.783562 0.667321,-1.929933 0.03318,-3.808638 -1.537509,-4.554996 -0.431211,-0.204902 -1.669379,-0.441649 -2.751485,-0.526104 l -1.967466,-0.153555 v 3.730264 3.730263 l 1.742612,-0.0049 c 1.249689,-0.0035 1.997026,-0.127259 2.642026,-0.437372 z m 46.432206,13.645118 c -5.24719,-1.800938 -8.35608,-5.688165 -8.89102,-11.116957 -0.28277,-2.869719 0.59483,-6.479663 2.10113,-8.642862 0.85791,-1.23204 2.58423,-2.893457 3.76148,-3.620074 1.47881,-0.912742 4.02119,-1.71865 5.92182,-1.877156 6.84,-0.570434 12.44807,3.217871 14.06479,9.500885 0.445,1.729392 0.45278,4.923227 0.0165,6.773662 -1.04804,4.445166 -4.54003,7.975603 -9.04285,9.1424 -2.12376,0.550323 -6.09586,0.470249 -7.93185,-0.159898 z m 7.0346,-4.789147 c 1.35518,-0.461756 2.75357,-1.836429 3.49116,-3.43195 0.47986,-1.038016 0.6042,-1.689693 0.67681,-3.547245 0.15886,-4.064464 -0.96934,Line truncated
id="path1"
sodipodi:nodetypes="sssssssssscssssccscssssscccccccsscccccccssssssssssscccsscccsssssccccssscccccccccccccccccccccccccccccccccccccsscsssssssssssssssscsssscssscccsccssssssssssssssssssscsscccsssssssssssssssssssssssccssssssssssssssssssssscsscscsssccccccsscsssssscsscssssssscccssssssscccsscsscsssssssscccssssssssccssssssssssssccccccssssssssssssscccccccccccccccccccccccccccccccsssscsssssssssssssscssssssssssssscssssssssssssssssscscssscssssssssssssssssscsscssssssssssssccsssssscssssssssssssssssssssscsssssssssssssssscsssssssscssssssssssscscsssssssssssccssscsscssssscsssscssssscssccssssssssssssssssscsscssccssssss" /></g></svg>

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 25 KiB