[reportlab-users] How to get elementary attributes of a document
Robert Szelepcsényi
robert at tankred.sk
Thu Jun 30 06:52:05 EDT 2011
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
More information about the reportlab-users
mailing list