The other day I had an interesting task I needed to complete with Reportlab. I needed to create a PDF in landscape orientation that had to be rotated 90 degrees when I saved it. To make it easier to lay out the document, I created a class with a flag that allows me to save it in landscape orientation or flip it into portrait. In this article, we’ll take a look at my code to see what it takes. If you’d like to follow along, I would recommend downloading a copy of and (or ).
is really nice tool for creating PDFs in Python. A little known fact is that they now support adding charts or graphs to your PDF. Previously if you wanted that functionality, you would have to do all the drawing code yourself. Unfortunately, the Reportlab guide doesn’t really explain how to use their charts, what kinds of charts are supported or what their parameters / attributes / etc are. They do have some example code snippets on their though. In this article, we’ll go over a couple of simple examples to show you how to use Reportlab’s charting capabilities.
easy_install ReportLab works for me.
That was easy! You’ve just created a really simple PDF! Note that the default Canvas size is A4, so if you happen to be American, you’ll probably want to change that to letter size. This is easy to do in Reportlab. All you need to do is the following:
ReportLab is the time-proven, ultra-robust open-source engine for creating complex, data-driven PDF documents and custom vector graphics. It's free, open-source , and written in Python. The package sees 50,000+ downloads per month, is part of standard Linux distributions, is embedded in many products, and was selected to power the print/export feature for Wikipedia.The open-source ReportLab Toolkit provides the core of our commercial product, ReportLab PLUS, which generates PDF at higher speed and allows use of our smart XML-based templating language RML. ReportLab PLUS contains significant upgrades over the open-source library that allows for a much faster development cycle. If you are putting substantial time into building a solution please consider the commercial version; it is faster, does more, and the revenues directly support ongoing development. You can .