87

What Python PDF libraries are there?

I need to make some PDF with many grids, and I'm looking for a library that allows to manage pages (multi-page). The library should calculate when the page is ended and then create the next page.

Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221
enfix
  • 6,680
  • 12
  • 55
  • 80
  • 1
    Maybe it could be rephrased to ask what libraries are suitable for generating appropriate PDFs for the askers use case. "The best" is too subjective. – Alpaca May 21 '14 at 02:43
  • With respect to your second "question" (pagebreaks) you might want to use `pdflatex`. – Tobias Kienzler Dec 02 '14 at 10:08
  • 3
    There is a nice tutorial, https://www.binpress.com/tutorial/manipulating-pdfs-with-python/167 that named some 5 libraries: pdfrw, slate, PDFQuery, PDFMiner, PyPDF2 – WebComer Oct 08 '15 at 01:05
  • [xhtml2pdf](https://github.com/xhtml2pdf/xhtml2pdf) is based on html templates and uses ReportLab. It's quite fast to grab and it answers the OP needs. – Ehvince Mar 19 '16 at 01:20
  • There's also [rinohtype](http://www.mos6581.org/rinohtype/), which is similar to LaTeX as it focuses on rendering structured documents. (full discloure: I am the author of rinohtype). – Brecht Machiels Dec 22 '16 at 13:28
  • check the [pdfme](https://github.com/aFelipeSP/pdfme) library. It's very powerful – Felipe Sierra Jul 14 '21 at 23:58

4 Answers4

35

The two that come to mind are:

Eduard Luca
  • 6,514
  • 16
  • 85
  • 137
Bryan
  • 6,529
  • 2
  • 29
  • 16
33

Reportlab. There is an open source version, and a paid version which adds the Report Markup Language (an alternative method of defining your document).

chhantyal
  • 11,874
  • 7
  • 51
  • 77
Rob Cowie
  • 22,259
  • 6
  • 62
  • 56
  • 1
    Reportlab is really good. Another good one for simple tasks and for people who know about html is xhtml2pdf. – Loïc Sep 01 '15 at 19:40
5

I already have used Reportlab in one project.

Zardust
  • 59
  • 2
3

There is also http://appyframework.org/pod.html which takes a LibreOffice or OpenOffice document as template and can generate pdf, rtf, odt ... To generate pdf it requires a headless OOo on some server. Documentation is concise but relatively complete. http://appyframework.org/podWritingTemplates.html If you need advice, the author is rather helpful.

Luc Saffre
  • 96
  • 2