Daniel Campos Cordero
Daniel Campos Cordero

Reputation: 21

PDF generation on Python 3.2

I'm trying to make a PDF file in Python, but all of the tools I find only work on Python 2.7 (or lower) and I'm using 3.2. I there a tool or something that works on 3.2 and generates PDF files? Or a way to make 2.7 (or lower) code work on 3.2?

Upvotes: 1

Views: 410

Answers (1)

J0HN
J0HN

Reputation: 26941

Not personally tested with Python 3.x, but official page says weasyprint works with it. It allows for HTML to PDF conversion, so depending on your needs and the rest of the project this may be an advantage or disadvantage.

For a low-level "draw the PDF yourself" you might want to try cairo, but looks like the automatic installation is a bit incomplete: Cairo example works with Python 2.7 but does not work in Python 3

To convert python 2.x code to python 3.x code you may use the following two tools:

  1. 2to3
  2. Your brain

The latter tool are much more powerful, and sort of guarantees successful conversion, but a little bit slow compared to the former.

Upvotes: 1

Related Questions