我想在一页上有两列包含文本数据。 当数据长度超过第一页时,将引发此错误:
Flowable <Table@0x7FC27FB76550 1 rows x 2 cols(tallest row 1770)> with cell(0,0) containing
'<Paragraph at 0x7fc27fb764a8>of everything a a and an an and with of find her powers Elsa'(439.27559055118115 x 1770),
tallest cell 1770.0 points, too large on page 2 in frame 'normal'(439.27559055118115 x 685.8897637795277*) of template 'Later'
这是我的代码:
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="file.pdf"'
buffer = BytesIO()
styles = getSampleStyleSheet()
doc = SimpleDocTemplate(buffer, pagesize=A4)
Story=[]
str1 = "Anna sets out on a journey with an iceman, Kristoff, and his reindeer, Sven, in order to find her sister, Elsa, who with the help of her powers mistakenly converts everything into ice.".split()
str2 = "Description Tony Stark encounters a formidable foe called the Mandarin. After failing to defeat his enemy, he embarks on a journey with relentless consequences and a suit that ceases to exist.".split()
tbl_data = [
[Paragraph(" ".join([random.choice(str1) for i in range(1000)]),styles['Normal']),
Paragraph(" ".join([random.choice(str2) for i in range(1000)]),styles['Normal'])]
]
tbl = Table(tbl_data)
Story.append(tbl)
doc.build(Story)
response.write(buffer.getvalue())
buffer.close()
return response
两列的长度可能会有所不同。 数据应继续流向后续页面,而不是卡在中间。 我该如何解决这个问题?