[reportlab-users] Printing Tuples From A List

Rich Shepard rshepard at appl-ecosys.com
Wed Oct 10 20:48:38 EDT 2007

I'm trying to learn ReportLab to produce the three types of reports we
need to have our model provide. Of the three, the simplest is a good place
to start.

I've re-read the doc, and tried working directly with the canvas rather
than using Platypus, but generate neither Python errors nor the specified
.pdf file.

My test file is attached. I've included one of the list of tuples
(EcoPairs) that would be fetched from the database in the actual

What have I done incorrectly here? When I understand how to produce output
from this list -- one tuple per row -- I want to use the textobject.move and
origin placements to align each row to the right of the OMR[1] form on which
these will be printed. Since we'll be printing the .pdf onto a preprinted
form, alignment will be critical.

Would this be done better using platypus rather than the direct canvas


[1] Optical Mark Recognition, a form on which people mark choices and those
are digitized using a scanner.

Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
-------------- next part --------------
#!/usr/bin/env python

from pysqlite2 import dbapi2 as sqlite3
from reportlab.pdfgen import canvas
from reportlab.lib import colors
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import LETTER, landscape, portrait

con = sqlite3.connect('burro-breath.db', isolation_level=None)
cur = con.cursor()

cur.execute("SELECT comp1, comp2 from Pairs where pair_cat='Economic'")
EcoPairs = cur.fetchall()

cur.execute("SELECT comp1, comp2 from Pairs where pair_cat='Natural'")
NatPairs = cur.fetchall()

cur.execute("SELECT comp1, comp2 from Pairs where pair_cat='Societal'")
SocPairs = cur.fetchall()


def outDo(c):
c = canvas
textobject = c.beginText()
textovject.setFont("Helvetica", 10)
textobject.setTextOrigin(0*inch, 9.0*inch)
for pair in EcoPairs:

c = canvas.Canvas("EcoPairs.pdf", pagesize=letter)



More information about the reportlab-users mailing list