[reportlab-users] Re: reset page numbers

David S. davidschein at alumni.tufts.edu
Wed Apr 19 09:53:40 EDT 2006


Robin Becker <robin <at> reportlab.com> writes:

> Therefore I suggest you consider a combination of a flowable which sets 
> a flag when rendered and then the beforePage method of the pageTemplate 
> can choose to reset the canvas._pageNumber.

Thank you for your help.  Here is a solution that works for me:

class PageNumberOne(Flowable):
  def draw(self):
    pass
    
class FsiDocTemplate(SimpleDocTemplate):
  "resets page number"
  def afterFlowable(self, flowable):
    if isinstance(flowable, Receipt.PageNumberOne):
      self.canv._pageNumber = 0

...
Then I add to my story a PageNumberOne and a reportlab.platypus.PageBreak to
start a new section with page number at 1.

Thanks again.

David S.






More information about the reportlab-users mailing list