linux - How to download the created PDF file in python? -
linux - How to download the created PDF file in python? -
i able convert html pdf , store on local directory. point how download same file after beeing created progamatically using python?
this code:filename = "test.pdf" body= fromstring( u"<div>" + tostring( fromstring( str(self.request.post['content']).decode('utf-8') ).body ) + u"</div>" ) tx = tostring(body).encode('utf-8') pisa.createpdf(tx, file(filename, 'wb'))
hi there founded solution:
fh = open('path_to_file','r') self._response.data = fh.read() fh.close() self._response.headers.add('content-type', 'application/pdf') self._response.headers.add('content-disposition', 'attachment')
so able download created file...
python linux
Comments
Post a Comment