我有一个使用Reportlab库生成PDF文件的方法:
def obtenerPDFNuevoPedido(self, handler,rsUsuarioPedido, rsPedido):
handler.response.headers['Content-Type'] = 'application/pdf'
handler.response.headers['Content-Disposition'] = 'attachment; filename=output.pdf'
story = []
story.append(Paragraph('CHIPAS', ParagraphStyle(name="centeredStyle", alignment=TA_CENTER, fontSize=20)))
story.append(Paragraph('____________ENLANUBE', ParagraphStyle(name="centeredStyle", alignment=TA_CENTER, fontSize=20)))
story.append(Spacer(6, 22))
story.append(Table([[Paragraph(str(strftime("%Y-%m-%d", gmtime())), ParagraphStyle(name="centeredStyle", alignment=TA_LEFT, fontSize=7)),
Paragraph(str(strftime("%H:%M:%S", gmtime())), ParagraphStyle(name="centeredStyle", alignment=TA_RIGHT, fontSize=7))]],colWidths=[5.05 * cm, 3.1 * cm]))
story.append(Paragraph("DEVELOPED AT ROSHKA-LABS", ParagraphStyle(name="centeredStyle", alignment=TA_CENTER, fontSize=6)))
story.append(Paragraph('-'*50, styleCentered))
#...
#...
doc = SimpleDocTemplate(handler.response.out, pagesize=letter)
doc.build(story)
当我调用该方法时,它会打开一个保存对话框,在那里我可以指定文件的保存位置。在
如何将生成的pdf文件保存在数据存储中?在
提前谢谢!在
1)您只能指定所需的文件名(而不是目标)
2)试试这个(未测试)
更换您的
^{pr2}$与
相关问题 更多 >
编程相关推荐