[reportlab-users] Page two more narrow than page one???

Magnus Lycka reportlab-users@reportlab.com
Tue, 21 Jan 2003 21:06:20 +0100

Hi, I've been lurking here more or less as long as the list
has existed, but I never really used ReportLab for real until
now. (Just admired it from a distance. ;) So I'm probably
doing some stupid newbie mistake...

I'm running rl 1.16 with py 2.2.1 on Win 2000. Default page
size is A4.

The code below will cause the following traceback if the
table is too long to fit in one page.

Traceback (most recent call last):
   File "H:\bampy\tabletest.py", line 38, in ?
   File "H:\bampy\tabletest.py", line 35, in go
   File "G:\Python22\reportlab\platypus\doctemplate.py", line 736, in build
   File "G:\Python22\reportlab\platypus\doctemplate.py", line 579, in build
   File "G:\Python22\reportlab\platypus\doctemplate.py", line 525, in 
     raise "LayoutError", message
LayoutError: Flowable <Table at 8346328 62 rows x 5 cols> with cell(0,0) 
'Description' too large on page 2

Huh? Is page 2 more narrow than page one? I tried making the
first column narrower, 8.4 cm cm instead of 9 cm, and then it
works ok! If it fits in one page I can expand the first column
until the text grows outside the paper... Why this difference
in behaviour in the first and second page. (It took me a while
before I understood what it was really complaining about...)

from reportlab.platypus import SimpleDocTemplate, Table
from reportlab.lib.units import cm

def M(amt): return "%.2f" % amt

def go():
     doc = SimpleDocTemplate('test.pdf')
     story = []
     head = ('Description', 'Amount', 'Unit', 'Unit Price', 'Sum')
     spec = [
     ('Consulting services blah blah blah', 5.5, 'hours', 6),
     ('Programming', 19, 'hours', 7),
     ('Software testing', 9, 'hours', 8),
     ] * 20 # If I reduce this to 10, it fits in one page and it works.
     data = [data + (data[1]*data[3],) for data in spec]
     sum = 0
     for row in data:
         sum += row[-1]
     data = [(x[0],"%.2f" % x[1], x[2], M(x[3]), M(x[4])) for x in data]
     data.insert(0, head)
     data.append(('','','','Net sum',M(sum)))
     t=Table(data, (9*cm, 1.5*cm, 1.5*cm, 2*cm, 2*cm))
     t.repeatRows = 1

if __name__ == '__main__':

I can't see what I'm doing / not doing here that is different from
the test code in tables.py, and that manages to split the Attribute /
Synonyms table...

Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se