def test_06_fontsize(self): from reportlab.lib.pagesizes import A4 from reportlab.pdfgen.canvas import Canvas from reportlab.lib.units import inch from reportlab.lib.colors import red, magenta c = Canvas('demo.pdf', pagesize=A4) c.translate(inch, inch) c.setFont("Times-Roman", 20) c.setFillColor(red) c.saveState() c.drawCentredString(2.75 * inch, 2.5 * inch, "Font size excmples") c.setFillColor(magenta) size = 7 x = 2.3 * inch y = 1.3 * inch for line in range(7): c.setFont("Helvetica", size) c.drawRightString(x, y, "%s points" % size) c.drawString(x, y, "test") y = y - size * 1.2 size = size + 1.5 c.restoreState() c.drawString(0, 0, "%s" % c.getAvailableFonts()) c.showPage() c.save()
def test_06_fontsize(self): from reportlab.lib.pagesizes import A4 from reportlab.pdfgen.canvas import Canvas from reportlab.lib.units import inch from reportlab.lib.colors import red, magenta c = Canvas('demo.pdf', pagesize=A4) c.translate(inch, inch) c.setFont("Times-Roman", 20) c.setFillColor(red) c.saveState() c.drawCentredString(2.75*inch, 2.5*inch,"Font size excmples") c.setFillColor(magenta) size = 7 x = 2.3 * inch y = 1.3 * inch for line in range(7): c.setFont("Helvetica", size) c.drawRightString(x, y, "%s points" % size) c.drawString(x,y, "test") y = y-size*1.2 size = size+1.5 c.restoreState() c.drawString(0,0, "%s" % c.getAvailableFonts()) c.showPage() c.save()
def pdf_demo_9(file): c = Canvas(file, pagesize=A4) x, y = 50 * mm, 280 * mm for font in c.getAvailableFonts(): c.setFont("Courier", 10) c.drawRightString(x - 5, y, font) c.setFont(font, 12) c.drawString(x + 5, y, "Quick brown fox jumped over the lazy dog") y -= 15 # Drop 15 point for each line c.setFont("Times-Italic", 10) c.drawCentredString(105 * mm, 10 * mm, "Page 1") c.save()