Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add page break to Reportlab Canvas object

I need to generate a 2 pages 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 the same page.

How should I add a page break to this Canvas instance ?

like image 353
juanefren Avatar asked Aug 29 '10 01:08

juanefren


1 Answers

Just call mycanvas.showPage() once page 1 is done -- this way, the rest of the output goes to page 2. See the docs.

like image 137
Alex Martelli Avatar answered Sep 16 '22 18:09

Alex Martelli