如何設置表格的左側位置?reportlab設置左表位置
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=%s' % pdf_name
buffer = StringIO()
PAGESIZE = pagesizes.portrait(pagesizes.A4)
doc = SimpleDocTemplate(buffer, pagesize=PAGESIZE, leftMargin=1*cm)
story = []
story.append(Paragraph(header_part2, styleN))
table_row = ['Total Score:','']
data.append(table_row)
ts = [
#header style
('LINEABOVE', (0,0), (-1,0), 1, colors.gray),
('LINEBELOW', (0,0), (-1,0), 1, colors.gray)]
t = Table(data, (6*cm,6*cm), None, style=ts)
story.append(t)
doc.build(story)
pdf = buffer.getvalue()
buffer.close()
response.write(pdf)
儘管段落從左側打印1釐米,但打印的表格幾乎沒有距左頁邊框的距離。
我必須在哪裏設置表格位置的leftMargin?
這同樣適用於我添加的圖像。他們似乎打印在某個地方。
story.append(Image(path,35,10))