3

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

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Vaisakh Cp
  • 171
  • 4
  • 11

3 Answers3

6

There are several options out there:

Also take a look at:

Hope that helps.

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • First of all , thanks for the suggestions. I tried reportlab as per your suggestion. But can i use it in my project. ? When i read the reportlab documentation, it says it will convert documents written in RML (Report Markup Language ) to PDF. – Vaisakh Cp Jul 31 '13 at 05:18
  • You are welcome. Yes, reportlab is the first option to try (and may be the last one too), see [an example](https://docs.djangoproject.com/en/dev/howto/outputting-pdf/) in django docs. – alecxe Jul 31 '13 at 06:03
2

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')
Leo
  • 153
  • 6
  • Thanks for the answer... But when i run the first line, ie "import webod" , it shows an error - 'import error: No module named 1xml. What to do ? I installed django-webodt from the link you mentioned. – Vaisakh Cp Jul 30 '13 at 09:47
1

Download and try this. The author wrote this:

PyText2Pdf makes a 7-bit clean PDF file from any input file.

It reads from a named file, and writes the PDF file to a file specified by the user, otherwise to a file with '.pdf' appended to the input file.

You could run it as stated below:

text2pdf.py rfc_3917.txt -S "Netflow RFC" -A "Quittek, et al." -K netflow,rfc,networking,ipfix -R "[Page\s+\d+]"

But check inside the script for more details.

A link to its usage in Django is here but partly outdated because the older script was used. The link I provided here is the newer one.

iChux
  • 2,266
  • 22
  • 37