[reportlab-users] Crashing when table goes over a page

Garth Kidd reportlab-users@reportlab.com
Sat, 9 Aug 2003 21:42:48 +1000


# > .... I suspect that's due to some floating point error 
# > propagation, but I need some simple encapsulated cases and I 
# > think I have lost the earlier ones. 
#
# Try this: 

from reportlab.platypus import SimpleDocTemplate, Paragraph, Table,
TableStyle
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colors

def tableOfDoom(rows): 
    td = []
    td.append(['hostname', 'timestamp', 'case', 'subject'])
    for rowNum in range(rows): 
        td.append(['parrot', 
                   '2003/01/01 13:00', 
                   '-', 
                   'Power Supply 2 is powered off
POWER_SUPPLY_DEGRADED!!!'])
    table = Table(td, repeatRows=1)
    return table

def buildTableOfDoom(rows): 
    fn = "tableOfDoom-%d.pdf" % rows
    print "Building %s (Table of Doom with %d rows)..." % (fn, rows)
    doc = SimpleDocTemplate(fn)
    styles = getSampleStyleSheet()
    doc.build([tableOfDoom(rows)])

if __name__ == '__main__': 
    for rows in range(5, 46, 5): 
        buildTableOfDoom(rows)

# Regards,
# Garth.