ReportLab Test

Nikolaus Gradwohl2008-09-10T09:03:00+00:00

I just have tested reportlab a python-framework for pdf generation.

from reportlab.pdfgen import canvas
from reportlab.lib.units import cm

c = canvas.Canvas("hello.pdf")

c.drawString(2*cm,28*cm,"Hello World")

c.line( 2*cm, 26*cm, 2*cm, 16*cm)
c.line( 2*cm, 16*cm, 12*cm, 16*cm )

c.setFillColorRGB( 0, 0, 1 )
c.rect( 2.5*cm, 16*cm, 1.5*cm, 7*cm, fill = 1 )
c.setFillColorRGB( 0, 1, 0 )
c.rect( 4.5*cm, 16*cm, 1.5*cm, 6*cm, fill = 1 )
c.setFillColorRGB( 1, 0, 0 )
c.rect( 6.5*cm, 16*cm, 1.5*cm, 8*cm, fill = 1 )


this little script generates a pdf containing 'hello world' and a simple bar-chart. i think i will give it a try if i have to generate pdf-reports the next time

Tweet This! submit to reddit Digg! Tags: | no comments | no trackbacks

See also:

rotated text in reportlabs
grease pencil experiment 6 - grid
grease pencil experiment 4 - filled shapes
grease pencil experiment 4 - depth of field
grease pencil experiment 3 - animated circles



Leave a response

Leave a comment