[reportlab-users] Reportlab footer issue

Asif Jamadar asif.jamadar at rezayat.net
Sat Jul 2 01:14:18 EDT 2011


May be this one helps you,

def HeaderFooter(canvas, doc):
canvas.saveState()

canvas.setFont('Times-Roman', 9)
canvas.drawString(280, 43, "Page %d" % doc.page)
canvas.drawImage("rezilabs.bmp", 43,820, width=1.3*inch,height=0.2*inch)
canvas.drawImage("RezayatLogo.bmp", 470,820, width=1.5*inch,height=0.3*inch)

canvas.restoreState()



and your main function will be

doc.build(Document, onLaterPages=HeaderFooter)



Message: 1
Date: Thu, 30 Jun 2011 12:52:05 +0200
From: Robert Szelepcs?nyi <robert at tankred.sk>
Subject: [reportlab-users] How to get elementary attributes of a
document
To: "'reportlab-users at lists2.reportlab.com'"
<reportlab-users at lists2.reportlab.com>
Message-ID:
<0C391C471C8A4845AB50B35165DEB557DAA81790 at delta.tankred.sk>
Content-Type: text/plain; charset="iso-8859-2"

Hi,



I need to generate invoices in PDF. Each invoioce has a footer. Also pages are to be numbered in the style Page X of Y.

Inorder to achieve this I provide my own functions for onFirstPage, onLaterPages, and canvasmaker in doc.build:

doc.build(elements,
onFirstPage=myFooter,
onLaterPages=myFooter,
canvasmaker=NumberedCanvas)


These functions work as expected. However, in order to format the output I need access to elementary attributes of the document: pagesize and margins.

For example I need to put page numbers to the bottom of the page in the middle. I can nail it down to fixed coordinates, which works without any problems, but I don't like this approach, because the document template can change.

I need to be able to get these attributes from canvas, which all the abovementioned functions get as one of their arguments.

I jus can't figure out how to read these attributes. For example leftmargin is mentioned in the whole documentation just once - where document template is created.

I suppose pagesize and margins must be stored somewhere - how can I read them?



Robert Szelepcsenyi


------------------------------

_______________________________________________
reportlab-users mailing list
reportlab-users at lists2.reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users


End of reportlab-users Digest, Vol 87, Issue 18
***********************************************


More information about the reportlab-users mailing list