[reportlab-users] Problems with filling cells with large paragraphs (LayoutError: Flowable)

Claudio Battaglino c.battaglino at icube.it
Wed Feb 1 10:57:03 EST 2006


Hi,
I've some two problems with cells containing long paragraphs.

First, running the following script I've a LayoutError because the cell 
contains a too large paragraph.
How can I solve this problem?

Second, if I have a string longer that the column size, with few blanks 
(long_string="thisisaverylongstring"), the content of the first column 
overflows into the second column.
Is it possible to force the paragraph to wrap to new line?

Thank you very much

claudio :-)




***script:

from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet
styles = getSampleStyleSheet()


def printPDF():
     doc = SimpleDocTemplate("test.pdf")
     Story = []
     cwidths = [ 1 * cm, 3 * cm]
     tableData = []
     first_string = "ciao "
     long_string =first_string * 100
     second_string = "bye bye"
     style = styles['Normal']
     long_paragraph = Paragraph(long_string, style)
     second_paragraph = Paragraph(second_string, style)


     tableData.append([long_paragraph, second_paragraph])
     table = LongTable(tableData, cwidths, \
         style=[('GRID', (0,0),(-1,-1), 1, colors.black)])
     Story.append(table)
     doc.build(Story)


if __name__=="__main__":
     printPDF()

***error:

claudio at millenium:~/Desktop$ python provarep.py
Traceback (most recent call last):
   File "provarep.py", line 29, in ?
     printPDF()
   File "provarep.py", line 25, in printPDF
     doc.build(Story)
   File 
"/usr/lib/python2.3/site-packages/reportlab/platypus/doctemplate.py", 
line 814, in build
     BaseDocTemplate.build(self,flowables)
   File 
"/usr/lib/python2.3/site-packages/reportlab/platypus/doctemplate.py", 
line 644, in build
     self.handle_flowable(flowables)
   File 
"/usr/lib/python2.3/site-packages/reportlab/platypus/doctemplate.py", 
line 586, in handle_flowable
     raise LayoutError("Flowable %s too large on page %d" % 
(f.identity(30), self.page))
reportlab.platypus.doctemplate.LayoutError: Flowable <LongTable at 
1079084396 1 rows x 2 cols> with cell(0,0) containing
'<Paragraph at 1079061452>ciao ciao ciao ciao ciao ciao ' too large on 
page 2


More information about the reportlab-users mailing list