简体   繁体   中英

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 ?

只需在第1页完成后调用mycanvas.showPage() - 这样,输出的其余部分将转到第2页。请参阅文档

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM