Dec-21-2022, 07:12 AM
(This post was last modified: Dec-21-2022, 07:12 AM by Pedroski55.)
Most printers can handle pdfs no trouble I think.
Why don't you make a pdf, then print that? Quick and easy!!
Also, if they are not throwaway barcodes, you can print them again and again!
Why don't you make a pdf, then print that? Quick and easy!!
Also, if they are not throwaway barcodes, you can print them again and again!
#! /usr/bin/python3 from reportlab.pdfgen import canvas # need this here from reportlab.lib.pagesizes import A4 # need this here from reportlab.pdfbase.ttfonts import TTFont # need this here from reportlab.pdfbase import pdfmetrics # need this here from reportlab.lib.units import mm import glob # to help you locate objects on the page # a reportlab page is in points of 1/72nd inch print('1mm is', mm, 'page points') # 2.834645669291339 # the sizes in points of an A4 page print('An A4 page is', A4, 'width by height in points.') fontpath = '/home/pedro/.local/share/fonts/' path2pdf = '/home/pedro/pdfs/' path2QRcodes = '/home/pedro/temp/QRcodes/' mypdf = 'mysizePDF.pdf' # this is the name of the pdf window title = 'A custom size pdf' # for Chinese ttfFile = os.path.join(fontpath, 'DroidSansFallbackFull.ttf') pdfmetrics.registerFont(TTFont("Droid", ttfFile)) qrcodes = glob.glob(path2QRcodes + '*.png') # insert the QR code def putQRcode(qrcode, myCanvas): # put the qr code on the page myCanvas.drawImage(qrcode, 350, 350, 100, 100, mask='auto') return myCanvas # bottom left corner is x=0, y=0 # c.showPage() puts a page break # set any custom pagesize with pagesize(x, y) def makePDF(): c = canvas.Canvas(path2pdf + mypdf, pagesize=(500, 500)) c.setTitle(title) # for Chinese #c.setFont('Droid', 18) c.setFont('Times-Roman', 14) for q in qrcodes: c.drawString(50, 400, "Welcome to Reportlab!") c.drawString(50, 380, "This is my custom pdf size") c = putQRcode(q, c) c.showPage() c.save() if __name__ == '__main__': makePDF()