[reportlab-users] Re: reset page numbers

Robin Becker robin at reportlab.com
Wed Apr 19 12:08:28 EDT 2006


David S. wrote:
> 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.
> 
...... that works fine if you're not trying to use the pageNumber in a document 
level method eg DocTemplate.afterPage or PageTemplate.afterDrawPage/onPageEnd
where the afterFlowable method would have already changed the pageNumber to zero.
-- 
Robin Becker


More information about the reportlab-users mailing list