![]() ![]() ![]() Other values are “ A3”, “ A5”, “ Letter,” and “ Legal.” pdf=PDF(format='A4') #page format. As you notice, the default value is “ A4”. Secondly, you can change the unit of measurement if you prefer units in “centimeter,” “points,” or “inches.” The default value is “mm: millimeter.” pdf=PDF(unit='mm') #unit of measurementįinally, the last parameter is the page format. ( It is case insensitive.) pdf=PDF(orientation='L') # landscape If you want to change it to landscape, use “ L” as orientation value. It is possible to use different directions like “ landscape” and “ portrait.” The default value of orientation is portrait. The FPDF constructor has a few parameters that affect the result. First, we need to create an object of the PDF class. class PDF(FPDF): pass # nothing happens when it is executed.Īfter creating a class, it is time to create our first pdf page. For the moment, we use the pass statement, which is a null operation. Initially, we create a class to use the FPDF library. FPDF is a PHP class that allows generating PDF files with pure PHP. We import the FPDF class from the “fpdf” package. python -m pip install fpdf # installation from fpdf import FPDF # fpdf class If you don’t have it yet, please check this link to install it. Let’s start with importing the “ FPDF” package. Admittedly, there are a lot of alternatives for creating a pdf in Python, but I prefer working with PyFPDF due to its simplicity. ![]() PyFPDF is a small and compact PDF document generation library under Python. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |