Compare commits

...

3 Commits

2 changed files with 77 additions and 8 deletions

View File

@@ -55,7 +55,7 @@ if __name__ == "__main__":
ticket_height = args.size
qr_code_size = ticket_height/1.5
logo = svg2rlg("img/karaoke-outline.svg")
logo = svg2rlg("img/karaoke-2-outline.svg")
scaling_factor = ticket_height/logo.height/2
logo.scale(scaling_factor, scaling_factor)
logo_width = logo.width*scaling_factor
@@ -71,6 +71,27 @@ if __name__ == "__main__":
generated_codes = 0
for page in range(required_pages):
# Add crop marks in the margin area
if args.margin > 4:
pdf.setLineWidth(0.01)
for row in range(codes_per_row):
x = args.margin+row*(ticket_width+args.gap)
pdf.line(x1=x, y1=1, x2=x, y2=args.margin-3)
pdf.line(x1=x, y1=page_height-1, x2=x, y2=page_height-args.margin+3)
if args.gap > 0 or row == codes_per_row-1:
pdf.line(x1=x+ticket_width, y1=1, x2=x+ticket_width, y2=args.margin-3)
pdf.line(x1=x+ticket_width, y1=page_height-1, x2=x+ticket_width, y2=page_height-args.margin+3)
for col in range(codes_per_col):
y = args.margin+col*(ticket_height+args.gap/1.2)
pdf.line(x1=1, y1=y, x2=args.margin-3, y2=y)
pdf.line(x1=page_width-1, y1=y, x2=page_width-args.margin+3, y2=y)
if args.gap > 0 or col == codes_per_col-1:
pdf.line(x1=1, y1=y+ticket_height, x2=args.margin-3, y2=y+ticket_height)
pdf.line(x1=page_width-1, y1=y+ticket_height, x2=page_width-args.margin+3, y2=y+ticket_height)
for y in range(codes_per_col):
for x in range(codes_per_row):
url = urljoin(args.url, generate_random_username(female_nouns, male_nouns, adjectives, used_usernames))
@@ -83,17 +104,24 @@ if __name__ == "__main__":
current_x = args.margin+(ticket_width+args.gap)*x
current_y = args.margin+(ticket_height+args.gap/1.2)*y
# Print outline around ticket for debugging
# pdf.setLineWidth(0.01)
# pdf.rect(current_x, current_y, ticket_width, ticket_height)
renderPDF.draw(logo, pdf, current_x, current_y+ticket_height*0.40)
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, current_x, current_y+35)
pdf.setFont("Helvetica", 12)
pdf.drawRightString(current_x+logo_width, current_y+16, "Hier anmelden →")
renderPDF.draw(drawing, pdf, current_x+logo_width, current_y+ticket_height*0.15)
pdf.setFont("Helvetica", 8)
pdf.drawRightString(current_x+logo_width+qr_code_size-7, current_y, url)
font_scale = ticket_height/100
pdf.setFont("Helvetica", 12*font_scale)
pdf.drawRightString(current_x+logo_width, current_y+ticket_height*0.25, "Hier anmelden →")
pdf.setFont("Helvetica", 8*font_scale)
pdf.drawRightString(current_x+logo_width+qr_code_size-7*font_scale, current_y+ticket_height*0.10, url)
renderPDF.draw(drawing, pdf, current_x+logo_width, current_y+5)
generated_codes += 1
if generated_codes >= args.number:
pdf.save()

41
img/karaoke-2-outline.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 32 KiB