Re: Setting TrueType fonts in table cell

Robin Becker <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
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
_______________________________________________
reportlab-users mailing list
[email protected]
http://two.pairlist.net/mailman/listinfo/reportlab-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.