0
reportlabを使用して長い文字列をpdfに出力する必要があります。コードは以下の通りです。問題は、コードが1ページである限り動作しますが、コンテンツが長すぎて、少なくとも2ページが必要な場合、longString変数はpdfには印刷されません。文字列が長すぎるときに改行を追加するにはどうすればよいですか。Django ReportLab複数ページのフレームを使用
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
# Create the PDF object, using the response object as its "file."
c = canvas.Canvas(response)
# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
longString= ""
styles = getSampleStyleSheet()
styleN = styles['Normal']
styleH = styles['Heading1']
story = []
story.append(Paragraph("This is a Heading",styleH))
story.append(Paragraph(longString, styleN))
f = Frame(inch, inch, 7*inch, 10*inch, showBoundary=0)
f.addFromList(story,c)
c.showPage()
c.save()
return response