我需要一個新的生產線,所以我可以看到在PFD的格式,我嘗試做添加頁面寬度,但它沒工作,我使用其他的事情與/ n,它並沒有工作。這是我的代碼。 我可以添加一個格式manualy因爲我需要顯示的信息,從數據庫獲取,我得到的信息在一個長長的一行。
def PdfReportView(request):
print id
# Create the HttpResponse object with the appropriate PDF headers.
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'filename="PatientReport.pdf"'
c = canvas.Canvas(response, pagesize=letter)
t = c.beginText()
t.setFont('Helvetica-Bold', 10)
t.setCharSpace(3)
t.setTextOrigin(50, 700)
t.textLine("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.")
c.drawText(t)
c.showPage()
c.save()
return response
你可能想看看'textwrap'庫(我想那就是它所謂的...) –