

Don’t forget to do that or you won’t get to see your new creation! You can change the location you start drawing by setting the bottomup canvas argument to 0. If you were to start drawing at (0, 0), your text would appear at the bottom left of the page. This code tells ReportLab to start drawing the text 100 points from the left and 750 from the bottom of the page. To add some text to the PDF, you use drawString(). You create a Canvas() object that takes in the path to the PDF that you want to create. My_canvas.drawString(100, 750, "Welcome to Reportlab!") Create a new file named hello_reportlab.py and add this code: # hello_reportlab.py It’s always easier to see some code so that you can understand how this will work.

There are several default page sizes that you can set or you can create your own page size. PDFs measure their size in points internally. This allows you to draw at specific locations on the page. The low-level method is drawing on the “canvas”. There are two ways to create PDFs using the ReportLab package. Now that you have ReportLab installed, you are ready to learn how to create a simple PDF! Creating a Simple PDF with the Canvas It will be installed as well if you do not already have it on your system. ReportLab depends on the Pillow package, which is an image manipulation library for Python. You can install ReportLab using pip: python3 -m pip install reportlab This article will not cover every feature that ReportLab has to offer, but you will learn enough about it to see how useful ReportLab can be. ReportLab can generate almost any kind of report you can imagine.

The ReportLab package has been around since the year 2000. In this article, you will learn how to create a PDF using ReportLab.

There are many other PDF packages for Python.
