我有一张桌子,我希望它在达到最大页面大小时将值打印到新的pdf页面上,我使用了报告实验室画布并将该表设置为画布。 为什么我们使用Wrapon DrawOn? 我的代码:
buffer = io.BytesIO()
p = canvas.Canvas(buffer)
data = [
['begin', 'begin', 'begin', 'begin', 'begin'],
['30', '31', '32', '33', '34'],
['00', '01', '02', '03', '04'],
['10', '11', '12', '13', '14'],
['20', '21', '22', '23', '24'],
['30', '31', '32', '33', '34'],
['00', '01', '02', '03', '04'],
['10', '11', '12', '13', '14'],
['30', '31', '32', '33', '34'],
['00', '01', '02', '03', '04'],
['10', '11', '12', '13', '14'],
['20', '21', '22', '23', '24'],
['end', 'end', 'end', 'end', 'end'],
]
t = Table(data, style=[
# ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
('LINEABOVE', (0, 1), (-1, 1), 1, colors.blue),
# ('VALIGN', (3, 0), (3, 0), 'BOTTOM'),
# ('ALIGN', (3, 1), (3, 1), 'CENTER'),
# ('ALIGN', (3, 2), (3, 2), 'LEFT'),
]
)
#What do they mean?
t.wrapOn(p, 220, 400)
t.drawOn(p, 220, 400)
p.save()
buffer.seek(0)
return buffer