forked from bvalgard/create-pdf-with-python-fpdf2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart_1.py
28 lines (23 loc) · 765 Bytes
/
part_1.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
from fpdf import FPDF
# create FPDF object
# Layout ('P','L')
# Unit ('mm', 'cm', 'in')
# format ('A3', 'A4' (default), 'A5', 'Letter', 'Legal', (100,150))
pdf = FPDF('P', 'mm', 'Letter')
# Add a page
pdf.add_page()
# specify font
# fonts ('times', 'courier', 'helvetica', 'symbol', 'zpfdingbats')
# 'B' (bold), 'U' (underline), 'I' (italics), '' (regular), combination (i.e., ('BU'))
pdf.set_font('helvetica', 'BIU', 16)
pdf.set_text_color(220,50,50)
# Add text
# w = width
# h = height
# txt = your text
# ln (0 False; 1 True - move cursor down to next line)
# border (0 False; 1 True - add border around cell)
pdf.cell(120, 100, 'Hello World!', ln=True, border=True)
pdf.set_font('times', '', 12)
pdf.cell(80, 10, 'Good Bye World!')
pdf.output('pdf_1.pdf')