[reportlab-users] Newby-question: Cannot initialize Table-objects

Robin Becker robin at reportlab.com
Sat Feb 16 16:40:14 EST 2008


Joost Behrends wrote:

> Hi,

>

> i will use reportlab in our small enterprise

> dealing historical picture postcards. A lot

> of work is done with my software - that means

> i need a lot of tables.

>

> The code of that software is fully portable and shall stay so.

> I'd strongly like to make all printing (including

> invoices etc. as e-mail attachments) through reportlab.

> end enjoyed my first experiences with the canvas.

> Everything worked from the first moment on -

> and exactly as described in the documentation. Seems

> to be great software - thanks for that.

>

> But getting to tables, i do not get them

> initialized correctly. Here is a very reduced

> example for isolating the problem:

>

> from reportlab.pdfgen import canvas

> from reportlab.platypus import Table

>

> atb = (('Hamburg', 'Germany', '1,760,322'),

> ('Paris', 'France', '9,644,507'),

> ('London', 'England', '8.278.251'))

>

> def drawTb(larg):

> cnv = canvas.Canvas('C:\\tmp\\tb.pdf',

> pagesize = (595.27, 841.89))

> tbOnPage = Table(larg)

> tbOnPage.drawOn(cnv, 0, 0)

> cnv.showPage()

> cnv.save()

> drawTb(atb)

>

> This produces:

>

.......
Table is a flowable and needs to be wrapped to determine the size.
Normally this is done by the doctemplate layout mechanism, but you're
not using that. Try using

tw, th = tbOnPage.wrapOn(cnv, 595.27, 841.89 )
prior to doing the drawOn
--
Robin Becker


More information about the reportlab-users mailing list