[reportlab-users] Experimenting with new paragraphs, splitting issue

Robin Becker robin at reportlab.com
Mon Dec 3 16:36:27 EST 2007


Dinu Gherman wrote:
........

> Ok, I've stripped down my sample code even further. It now should

> generate only one line of text spread over two little frames. When

> I use the RL paragraph class for doing this I get the following

> traceback:

>

> $ py251 test_twoframes.py

> Traceback (most recent call last):

> File "test_twoframes.py", line 49, in <module>

> main()

> File "test_twoframes.py", line 45, in main

> doc.build(story)

> File

> "/usr/local/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",

> line 740, in build

> self.handle_flowable(flowables)

> File

> "/usr/local/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",

> line 671, in handle_flowable

> raise LayoutError(ident)

> reportlab.platypus.doctemplate.LayoutError: Flowable <Paragraph at

> 0x10f54e0 frame=F2>aaaaaaa bbbbbbb ccccccc ON_NEX too large on page 1

>


Dinu, I'm probably not going to get much time to look at this till the
weekend, but looking at the Paragraph version I see no problem.

We try to wrap a height 40 paragraph in available height 30. That fails,
but the split cannot reduce the height. We flip to the next frame (also
with available height 30) and try again; that fails so we give up. You
probably wonder why we won't split into two lines. That is a hack in
Paragraph.py where we always fail to split if trying to return a first
split with only one line in. The intention is to avoid an orphan. If you
intend to split lines into frames with only one line in them we need a
different concept of layout.



> When I use my own (attached) paragraph class, I get the following

> traceback (preceeded by some debugging info):

>

> $ py251 test_twoframes.py

> *** parse aaaaaaa bbbbbbb ccccccc ON_NEXT_LINE

> *** wrap (240.000000, 30.000000)

> *** wrap (240.000000, 40.000000) needed

> *** parse aaaaaaa bbbbbbb ccccccc ON_NEXT_LINE

> *** split (240.000000, 30.000000)

> p1 aaaaaaa bbbbbbb ccccccc

> p2 ON_NEXT_LINE

> *** parse aaaaaaa bbbbbbb ccccccc

> *** wrap (240.000000, 30.000000)

> *** wrap (240.000000, 20.000000) needed

> *** parse ON_NEXT_LINE

> *** wrap (240.000000, 4.000000)

> *** wrap (240.000000, 20.000000) needed

> *** parse ON_NEXT_LINE

> *** split (240.000000, 4.000000)

> p1

> p2 ON_NEXT_LINE

> *** parse

> *** wrap (240.000000, 4.000000)

> *** wrap (240.000000, 20.000000) needed

> Traceback (most recent call last):

> File "test_twoframes.py", line 49, in <module>

> main()

> File "test_twoframes.py", line 45, in main

> doc.build(story)

> File

> "/usr/local/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",

> line 740, in build

> self.handle_flowable(flowables)

> File

> "/usr/local/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",

> line 663, in handle_flowable

> raise LayoutError(ident)

> reportlab.platypus.doctemplate.LayoutError: Splitting error(n==2) on

> page 1 in

> <Paragraph at 0x10f5738 frame=F1>ON_NEXT_LINE

>

> To me it seems like RL is already doing the wrong thing, given the

> first traceback above. And apart from that, I don't understand why

> RL calls my pararaph's split method the second time with an y value

> of 4.0 as you cen see in the debugging info above? I've run this

> with RL-SVN, BTW.



.......
I suspect this error comes because you're being a bit clever about the
split paragraphs. Remember that the outer packing loop tries to be as
stupid as possible. The split purported to return a first flowable for
which the wrap would succeed. Apparently in this case although the split
returned 2 flowables the attempt to re-add the first with the existing
frame parameters failed.
--
Robin Becker


More information about the reportlab-users mailing list