[reportlab-users] PageBreak: wrong documentation within flowable.py

Andy Robinson andy at reportlab.com
Mon Sep 3 05:38:38 EDT 2012

This works the way we always intended it. If the user wants to inject
a page break into their story, they do it by adding one of these
flowables. This works by using up all the remaining space in the
frame, which in turn lets our main loop handle the event itself. The
general idea is that the producer of content wants to put something
'in the story', rather than explicitly calling methods of the
doctemplate when they want things to happen.

This gets much clearer if you are working in RML, where you need to
put a tag in saying '<pageBreak/>' as you don't have access to call
the underlying template object.

There are also a number of other special cases our engine has to look
out for - for example, the PTO ('Please Turn Over') flowable, When
the user says 'PageBreak', this needs to be able to inject trailing
content onto the current frame. So we could not simply call the
method which triggers a move to the next page.

I am always open to simplifications. Have you tried changing it and
running all the tests (which, regrettably, involves eyeballing a lot
of PDFs)?



On 3 September 2012 09:20, Massa, Harald Armin <chef at ghum.de> wrote:

> Hello,


> I am working on a PageBreak that only breaks if it is not on the top

> of a page (i.e., if by chance a natural PageBreak has just happened,

> do not add an empty Page)


> During analysis I read within flowable.py:


> class UseUpSpace(NullDraw):

> def __init__(self):

> pass


> def __repr__(self):

> return "%s()" % self.__class__.__name__


> def wrap(self, availWidth, availHeight):

> self.width = availWidth

> self.height = availHeight

> return (availWidth,availHeight-1e-8) #step back a point


> class PageBreak(UseUpSpace):

> """Move on to the next page in the document.

> This works by consuming all remaining space in the frame!"""



> and tried to learn about "availWidth" and stuff... only to learn that

> this documentation is ... from some other time.

> PageBreak in current reportlab is handled by the method


> def handle_pageBreak(self,slow=None):


> within the Doc-Template.


> So I suggest to:


> a) derive PageBreak just from flowable

> b) update the docstring to


> class PageBreak(Flowable):

> """Move on to the next page in the document.

> this is done by the method handle_pageBreak within the

> Doc-Template, which is triggered by

> a flowable with this Class"""


> Best wishes


> Harald


> --



> Harald Armin Massa

> Spielberger Straße 49

> 70435 Stuttgart

> 0173/9409607


> Amtsgericht Stuttgart, HRB 734971

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

Andy Robinson
Managing Director
ReportLab Europe Ltd.
Thornton House, Thornton Road, Wimbledon, London SW19 4NG, UK
Tel +44-20-8405-6420

More information about the reportlab-users mailing list