如何设置表格的左侧位置?
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))