[reportlab-users] Setting TrueType fonts in table cell

Robin Becker robin at reportlab.com
Thu Sep 26 09:16:24 EDT 2013


Hi Nils,

I think the error is that you are re-using the canvas at the end of the build.

Effectively you are re-using the canvas page and saving it again. That
probably means you are re-defining the subset fonts again in the document.

I think the intent is for your extra code to write on the last document page.

The correct way to do that is to to have your page template have an onPageEnd
attribute.


On 25/09/2013 22:36, Nils Smeds wrote:
............

> PDFdoc.build(PDFdoc_elements)

>





> PDFcanvas=PDFdoc.canv

>

> PDFcanvas.setStrokeColorRGB(132.0/255,0.0/255,50.0/255)

> PDFcanvas.setFont("Courier", 20)

> PDFcanvas.drawString(5*cm, page_height - 8*cm, 'Č TALLY HOOO!!! č')

> PDFcanvas.setFont("SansB", 20)

> PDFcanvas.drawString(5*cm, page_height - 10*cm, 'Č TALLY HOOO!!! č')

>

> PDFcanvas.showPage()

> PDFcanvas.save()


SimpleDocTemplate doesn't really allow you to specify the onPageEnd attributes
too easily, but you can get the onPage attributes set fairly easily eg



> def myOnPage(PDFcanvas,doc):

> PDFcanvas.setStrokeColorRGB(132.0/255,0.0/255,50.0/255)

> PDFcanvas.setFont("Courier", 20)

> PDFcanvas.drawString(5*cm, page_height - 8*cm, 'C TALLY HOOO!!! c')

> PDFcanvas.setFont("SansB", 20)

> PDFcanvas.drawString(5*cm, page_height - 10*cm, 'C TALLY HOOO!!! c')

..........

> PDFdoc.build(PDFdoc_elements,onFirstPage=myOnPage,onLaterPages=myOnPage)


--
Robin Becker


More information about the reportlab-users mailing list