Add page break to ReportLab Canvas object

I need to create a two page pdf report. Pages are completely independent. tried using:

mycanvas.drawString(x, y, "Printing on Page 1") mycanvas._pageNumer = 2 mycanvas.drawString(x, y, "Printing on Page 2") 

and

 mycanvas.drawString(x, y, "Printing on Page 1") P = PageBreak() P.drawOn(mycanvas, 0, 1000) mycanvas.drawString(x, y, "Printing on Page 2") 

But everything is printed on one page.

How to add a page break to this canvas instance?

+9
python reportlab
source share
1 answer

Just call mycanvas.showPage() as soon as page 1 is ready - this way the rest of the output goes to page 2. See the docs .

+21
source share

All Articles