Sunday, April 22, 2018

Reportlab Module

Hey guys, I have found a cool module to print anything to pdf format. The name of the module is reportlab. If you have pip installed in your system then simply write the following in command prompt.

>>> pip install reportlab

The reportlab will automatically be detected anddownloaded if you have a proper internet connection.
Below is a simple code to run and print pdf file form python -

from reportlab.pdfgen import *
def hello(c):
    c.drawString(100,100,"Hello World")
c=canvas.Canvas("hello.pdf")
hello(c)
c.showPage()
c.save()

The code will create a file hello.pdf with "Hello World" written on it. If you want to learn more about reportlab below is the link to learn more - 

1 comment:

Feautured Post

Python Trivia Post: enumerate()

Python has a very useful inbuilt function, which is called enumerate(). This is needed whenever you need the numbering of a certain element...