Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django-python how to convert text to pdf

Tags:

python

pdf

django

I am doing a project in python-django, i would like to know whether there is any built-in library or something like that, that can convert text to pdf. Something similar to pyTeaser for converting image to text

Thanks in Advance

like image 729
Vaisakh Cp Avatar asked Feb 04 '26 01:02

Vaisakh Cp


2 Answers

There are several options out there:

  • reportlab (suggested by django docs)
  • PDFMiner (or +slate wrapper)
  • pdfrw
  • xhtml2pdf
  • pyfpdf (no changes since august, 2012)
  • pyPdf (not maintained)

Also take a look at:

  • Python PDF library
  • Outputting PDFs with Django
  • Open Source PDF Libraries in Python
  • Generating PDFs with Django
  • Django, ReportLab PDF Generation attached to an email
  • A Simple Step-by-Step Reportlab Tutorial
  • Django output pdf using reportlab

Hope that helps.

like image 88
alecxe Avatar answered Feb 05 '26 17:02

alecxe


I have been using django-webodt for a few days now to convert OpenOffice template (.odt) dynamically into PDF filling placeholders with database models.

test.odt could be...

Hello {{ first_name }}

import webodt
template = webodt.ODFTemplate('test.odt')
context = dict(first_name="Mary")
document = template.render(Context(context))
from webodt.converters import converter
conv = converter()
pdf = conv.convert(document, format='pdf')
like image 31
Leo Avatar answered Feb 05 '26 17:02

Leo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!