New bades

This commit is contained in:
Julian M. Kunkel 2019-03-04 12:13:09 +00:00
parent 6ed5f7f17f
commit dfd6dafba2
9 changed files with 64 additions and 0 deletions

64
badges/create-sticky-bades.py Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import traceback
from Reader import *
# Copyright by JK 2018
# License: MIT
# https://www.reportlab.com/docs/reportlab-userguide.pdf
if len(sys.argv) > 1:
event = sys.argv[1]
else:
event = "Use ARG1 as event"
print("This script generates a template for the Avery L7173 form")
data = loadData()
doc = PDFDoc("badges-A4", 21, 29.7)
c = 0
for p in data:
try:
# check for image
if c % 10 == 0:
offset_x = 0.1
elif c % 10 == 5:
offset_x = 10.2+0.3+0.1
if c % 5 == 0:
offset_y = 0.1
else:
offset_y += 5.95
img = doc.subImage(offset_x, offset_y , 10.2, 5.95)
img.addImg("../assets/background", 0, 0, 0.7)
img.addImg("../assets/reading-logo", 0.1, 0.8, 0.1)
img.addKeyVal("Department of", 0.37, 0.87, size=0.035, color=(0,0.2,0), font="Helvetica")
img.addKeyVal("Computer Science", 0.37, 0.81, size=0.05, color=(0,0.2,0), font="Helvetica")
#img.addImg("logo", 0.7, 0.8, 0.1)
#img.drawRectBorder(0, 0, 1, 1)
size = 0.2
if len(p[0]) > 12:
size = 0.2 * 12 / len(p[0])
img.addKeyValCenter(p[0], 0.5, 0.5, size=size, font="Helvetica")
img.addKeyValCenter(p[1], 0.5, 0.37, size=0.07, font="Helvetica-Oblique")
img.addKeyValCenter(event, 0.5, 0.2, size=0.07, font="Helvetica-Oblique")
if c % 10 == 9:
doc.newpage()
c+=1
except:
print("Unexpected error when processing %s" %(p))
traceback.print_exc()
doc.save()
print("In printing dialog set the defaults for scaling but use the manual feed!")