达到页面大小末尾时如何在报表实验室pdf中制作表格以打印在下一页上

时间:2018-11-30 22:26:07

标签: python django reportlab

我在django的报表实验室中有一个表,我希望它在到达A4页末尾时继续在下一页上打印其值。 在打印时,他们有什么办法跟踪当前位置吗?而t.wrapOn和t.drawOn是什么意思?

我的Django代码:

buffer = io.BytesIO()
p = canvas.Canvas(buffer)

width, height = A4
data = [


    ['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'],
    ['20', '21', '22', '23', '24'],
    ['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'],
    ['20', '21', '22', '23', '24'],
    ['30', '31', '32', '33', '34'],
    ['00', '01', '02', '03', '04'],
    ['10', '11', '12', '13', '14'],


]

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'),
                    ]
                    )


h = 100.0
t.wrapOn(p, width, height)
t.drawOn(p, *coord(8.8, 1.0, cm))


p.save()

buffer.seek(0)
return buffer

0 个答案:

没有答案