我的桌子太长了,超出了一页。
我知道使用doc.build很容易解决这个问题,但是我使用的是canvas.save,并且想知道是否可以在不将所有代码切换到doc.build的情况下将表拆分到多个页面。
以下是一些示例代码:
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image, Table, TableStyle
from reportlab.lib.colors import pink, green, brown, white, black, gray
from reportlab.lib.units import inch
canvas = canvas.Canvas("CoverSheet.pdf", pagesize=letter)
data = ['1','2','3','4','5','6','7','8','9']
table = Table(data)
table.setStyle(TableStyle([
('INNERGRID', (0,0), (-1,-1), 0.25, black),
('BOX', (0,0), (-1,-1), 0.25, black),
]))
w, h = table.wrapOn(canvas, inch * 1, inch * 4)
table.drawOn(canvas, inch * 1, inch * 1 - h)
canvas.save()
我需要做些什么才能让表格继续下一页?