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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -