forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.py
34 lines (25 loc) · 851 Bytes
/
basic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from fpdf import FPDF
# Author: @NavonilDas
pdf = FPDF()
# Set Author Name of the PDF
pdf.set_author("@NavonilDas")
# Set Subject of The PDF
pdf.set_subject("python")
# Set the Title of the PDF
pdf.set_title("Generating PDF with Python")
pdf.add_page()
# Set Font family Courier with font size 28
pdf.set_font("Courier", "", 18)
# Add Text at (0,50)
pdf.text(0, 50, "Example to generate PDF in python.")
# Set Font Family Courier with italic and font size 28
pdf.set_font("Courier", "i", 28)
pdf.text(0, 60, "This is an italic text") # Write text at 0,60
# Draw a Rectangle at (10,100) with Width 60,30
pdf.rect(10, 100, 60, 30, "D")
# Set Fill color
pdf.set_fill_color(255, 0, 0) # Red = (255,0,0)
# Draw a Circle at (10,135) with diameter 50
pdf.ellipse(10, 135, 50, 50, "F")
# Save the Output at Local File
pdf.output("output.pdf", "F")