7
Tôi có một phương pháp mà tạo ra một tập tin PDF bằng cách sử ReportLab thư viện:Làm thế nào để tiết kiệm tạo PDF với ReportLab để Datastore trong App Engine Python
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)
khi tôi gọi phương thức đó, nó sẽ mở ra một hộp thoại lưu, nơi tôi có thể chỉ định nơi lưu tệp.
Tôi nên làm gì để lưu tệp pdf được tạo trong kho dữ liệu?
Cảm ơn trước!
Cảm ơn russenreaktor! Tôi đã chỉnh sửa hai dòng câu trả lời của bạn =). Nó hoạt động như quyến rũ !. – Lucas