Задать вопрос

Тел: +7 965 3737 888

532

Просмотров

0

Ответов

pyText2Pdf - Python script to convert plain text into PDF file. Modified to work with streams.

<p>This is "pyText2Pdf" - Python script to convert plain text into PDF file. 
Originally written by Anand B Pillai.
It is taken from http://code.activestate.com/recipes/189858/</p>
<p>Modified to work with streams.</p>
<p>Example: produce PDF document from text and output it as HTTPResponse object.</p>
import StringIO
input_stream = StringIO.StringIO(text)
result = StringIO.StringIO()

pdfclass = pyText2Pdf(input_stream, result, "PDF title")
pdfclass.Convert()

response = HttpResponse(result.getvalue(), mimetype="application/pdf")
response['Content-Disposition'] = 'attachment; filename=pdf_report.pdf'

return response

Вопрос полезен? Да0/Нет0
file_3626.py(15.2Кб)
None