Distrotech / reportlab

Mirror of https://bitbucket.org/rptlab/reportlab
Other
59 stars 42 forks source link

reportlab LayoutError: Flowable Spacer too large #4

Open kouroshparsa opened 8 years ago

kouroshparsa commented 8 years ago

With reportlab 3.2.0, I get

SPACER = Spacer(0, 10)
buff = BytesIO()
doc = SimpleDocTemplate(buff, rightMargin=0.2 * inch,
                        leftMargin=0.2 * inch,\
                        topMargin=100, bottomMargin=68)
elements = []
# here add elements
elements.append(SPACER)
# here add more elements
doc.build(elements)

I sometimes get this exception:

File "/venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py", line 1171, in build
    BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
  File "/venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py", line 927, in build
    self.handle_flowable(flowables)
  File "/venv/lib/python2.7/site-packages/reportlab/platypus/doctemplate.py", line 829, in handle_flowable
    raise LayoutError(ident)
LayoutError: Flowable <Spacer at 0x4c87d40 frame=normal>...(0 x 10) too large on page 2 in frame 'normal'(554.475590551 x 661.88976378) of template 'Later'

This is happening when trying to insert the SPACER near the bottom of the page. Increasing bottomMargin would avoid the exception meaning that whenever SPACER height * character height >= doc.bottomMargin the reporter might fail if the space is close to the bottom of the page. discussed: http://stackoverflow.com/questions/35494584/reportlab-layouterror-flowable-spacer-too-large/35516604#35516604

The expected behavious is that it should not fail. It should somehow handle that.