I am looking for a library to create PDFs in Python. Preferably something simple to use as I don't know a great deal about the PDF format at present (so an HTML to PDF converter would be convenient).

I want to create an invoice from our booking system. The rest of the system is built in Django. The output isn't especially complex.

  • 1
    Create PDFs from what? Are there any input documents, and which format they are in? Is it OK if only HTML input is accepted?
    – Izzy
    Commented Jun 17, 2016 at 11:15
  • 2
    That should mean HTML input would be OK, as you would generate that yourself anyway, right?
    – Izzy
    Commented Jun 17, 2016 at 14:43
  • Yes, HTML would be nice, as I already know how to create document that way. Commented Jun 19, 2016 at 9:56

4 Answers 4


Probably the most well-known pdf generator toolkit, written in python, is reportlab which has an open-source version, as well as a more sophisticated licensed version. I found it hard to tweak, as a neophyte, to do exactly what I wanted.

Something more basic and simple to understand is pyfpdf which is open-source but there is the possibility of paid-for support. It is a python version of the popular php fpdf library.

Both are multiplatform.


You could generate your pdfs using LaTeX. There is PyLaTeX python library, which is an interface for LaTeX in python. This example covers most of the basics.


Have you noticed that official Django documentation has a How-To about "Outputting PDFs with Django". The key information is how to write Django views that dynamically generate PDF documents. It is a very concise way to get first results.

A drawback with reportlab is that you have to know a great deal about PDFs. That is why I would like to recommend solutions where web templates, built with HTML and CSS, are rendered to PDF. This approach should fit more into heads of web developers nowadays. But the tooling is always important as well and the reportlab way is well explored and documented. At least this is my two cents.


The best way to do that I founded is pdfkit. You also need to install wkhtmltopdf because pdfkit is a wrapper for it. Behind the scenes it converts an html to PDF. This is very nice to ease the formatting.

You can adjust margins, and paper size. I used it in Ubuntu/linux and Windows as well. I recommend it!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.