Using ReportLab with Python CSV module to Create PDF Files
Hi,Today am going to work you through the process of generating let’s say: “Course Completion Certificate” for any number of participants. This technique will work perfectly from one participant to hundreds and thousands of participants.
Let’s imagine a situation where you have to generate 2000 similar certificate with just few details/items changing from the template. That is to say details like; name, course title and grade will need to be unique for each generated certificate.
We are going to use the Python PDF library named: ReportLab. It is not distributed with that standard library, so you’ll need to download it if you want to run the examples in this tutorial.
Reportlab supports most of the normal Python library installation methods. You have the option of using "pip install reporlab" or downloading the source and running “python setup.py install” or running a binary installer (on Windows).
Creating a Simple PDF
Let’s see how to actually create a basic pdf file! In Reportlab, the lowest-level component that’s used regularly is the canvas object from the pdfgen package which allow you to “paint” a document with your text, images, lines or whatever.
from reportlab.pdfgen import canvas
c = canvas.Canvas("fileName.pdf")
c.drawString(100,750,"This is my first PDF file in Reportlab!")
c.save()
The code above creates and save a .pdf file in the same working directory with the name "fileName.pdf". The "drawString" method draw text wherever you tell it to, in this case is at coordinate position (100,750). We can as well replace the content text "This is my first PDF file in Reportlab!" with a dynamic variable as we will see later.
This the very basic code to generate a pdf file with reportlab python library. You can find more tutorials and code snippet on reportlab website.

