[reportlab-users] How are split, wrap, wrapOn supposed to work?

Robin Becker robin at reportlab.com
Tue Nov 18 06:49:23 EST 2014

Hi Henning,

I started to look at this in a cut down test (see attached).

However I am getting errors in the released version of wordaxe eg

 >>> from wordaxe.rl.NewParagraph import Paragraph
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
line 1185, in <module>
     from reportlab.lib.utils import fp_str
ImportError: cannot import name fp_str

should I be using the latest code?

Any how here are the calls that were made to the standard paragraph Wrap function

(twordaxe) C:\code\hg-repos\reportlab\tmp\twordaxe>timageandflowables.py

Paragraph at 0303fe48.wrap(*(-3.000000000000057, 268435455),**{})-->(7.9135, 5352)

Paragraph at 0303fe48.wrap(*(439.27559055118104, 
268435455),**{})-->(439.27559055118104, 60)

ImageAndFlowables at 02ee5d48.wrap(*(439.27559055118104, 
662.3897637795275),**{})-->(439.27559055118104, 238.71023622047244

Paragraph at 0303fe48.wrap(*(439.27559055118104, 
268435455),**{})-->(439.27559055118104, 60)

so it appears as though the base Paragraph tries to lay out something based on 
the negative width and returns an area that cannot fit.
> Henning
Robin Becker

-------------- next part --------------
import os
from functools import wraps
def logger(f):
    def wrapper(*args,**kwds):
        r = f(*args,**kwds)
        name = f.__name__
        if hasattr(f,'__self__'):
            self = f.__self__
            name = '%s@%8.8x.%s' % (self.__class__.__name__,id(self),name)
        print('\n\n%s(*%r,**%r)-->%r' % (name,args,kwds,r))
        return r
    return wrapper
def main():
    from reportlab.platypus.flowables import ImageAndFlowables, Image
    from reportlab.platypus.doctemplate import SimpleDocTemplate
    if os.environ.get('RL_USE_WORDAXE','0')=='1':
        from wordaxe.rl.styles import getSampleStyleSheet, ParagraphStyle
        from wordaxe.rl.NewParagraph import Paragraph
        from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
        from reportlab.platypus.paragraph import Paragraph
    gif = 'pythonpowered.gif'
    story = []
    styleSheet = getSampleStyleSheet()
    h3 = styleSheet['Heading3']
    bt = styleSheet['BodyText']
    p = Paragraph('''The concept of an integrated one box solution for advanced voice and
data applications began with the introduction of the IMACS. The
IMACS 200 carries on that tradition with an integrated solution
optimized for smaller port size applications that the IMACS could not
economically address. An array of the most popular interfaces and
features from the IMACS has been bundled into a small 2U chassis
providing the ultimate in ease of installation.''',
                            spaceBefore = 9.5,
    p.wrap = logger(p.wrap)
    p.split = logger(p.split)
    i = ImageAndFlowables(
    i.wrap = logger(i.wrap)
    i.split = logger(i.split)
    story.append(Paragraph('Image larger than the frame',h3))
    doc = SimpleDocTemplate('test-henning-case.pdf',showBoundary=1)

if __name__=='__main__':

More information about the reportlab-users mailing list