-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
219 lines (189 loc) · 6.22 KB
/
example.py
File metadata and controls
219 lines (189 loc) · 6.22 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
"""
Example of how to use ez_pdf
"""
from ez_pdf.ez_pdf import EzPDF
# Create New PDF
print("Creating New PDF")
pdf = EzPDF()
# Add Page
print("Adding Page")
pdf.add_page()
# Add 1 Cell Row - Align Center
print("Adding 1 Cell Row - Align Center")
pdf.add_one_cell_row("Add 1 Cell Row - Align Center")
# Add 2 Cell Row - Align Center
print("Adding 2 Cell Row - Align Center")
pdf.add_two_cell_row(
cell1_text="Add 2 Cell Row - Cell 1 - Align Center",
cell2_text="Add 2 Cell Row - Cell 2 - Align Center",
)
# Add 3 Cell Row - Align Center
print("Adding 3 Cell Row - Align Center")
pdf.add_three_cell_row(
cell1_text="Add 3 Cell Row - Cell 1 - Align Center",
cell2_text="Add 3 Cell Row - Cell 2 - Align Center",
cell3_text="Add 3 Cell Row - Cell 3 - Align Center",
)
# Add 4 Cell Row - Align Center
print("Adding 4 Cell Row - Align Center")
pdf.add_four_cell_row(
cell1_text="Add 4 Cell Row - Cell 1 - Align Center",
cell2_text="Add 4 Cell Row - Cell 2 - Align Center",
cell3_text="Add 4 Cell Row - Cell 3 - Align Center",
cell4_text="Add 4 Cell Row - Cell 4 - Align Center",
)
# Add 5 Cell Row - Align Center
print("Adding 5 Cell Row - Align Center")
pdf.add_five_cell_row(
cell1_text="Add 5 Cell Row - Cell 1 - Align Center",
cell2_text="Add 5 Cell Row - Cell 2 - Align Center",
cell3_text="Add 5 Cell Row - Cell 3 - Align Center",
cell4_text="Add 5 Cell Row - Cell 4 - Align Center",
cell5_text="Add 5 Cell Row - Cell 5 - Align Center",
)
# Add 1 Cell Row - Align Left
print("Adding 1 Cell Row - Align Left")
pdf.add_one_cell_row("Add 1 Cell Row - Align Left", align="L")
# Add 2 Cell Row - Align Left
print("Adding 2 Cell Row - Align Left")
pdf.add_two_cell_row(
cell1_text="Add 2 Cell Row - Cell 1 - Align Left",
cell2_text="Add 2 Cell Row - Cell 2 - Align Left",
cell1_align="L",
cell2_align="L"
)
# Add 3 Cell Row - Align Left
print("Adding 3 Cell Row - Align Left")
pdf.add_three_cell_row(
cell1_text="Add 3 Cell Row - Cell 1 - Align Left",
cell2_text="Add 3 Cell Row - Cell 2 - Align Left",
cell3_text="Add 3 Cell Row - Cell 3 - Align Left",
cell1_align="L",
cell2_align="L",
cell3_align="L"
)
# Add 4 Cell Row - Align Left
print("Adding 4 Cell Row - Align Left")
pdf.add_four_cell_row(
cell1_text="Add 4 Cell Row - Cell 1 - Align Left",
cell2_text="Add 4 Cell Row - Cell 2 - Align Left",
cell3_text="Add 4 Cell Row - Cell 3 - Align Left",
cell4_text="Add 4 Cell Row - Cell 4 - Align Left",
cell1_align="L",
cell2_align="L",
cell3_align="L",
cell4_align="L"
)
# Add 5 Cell Row - Align Left
print("Adding 5 Cell Row - Align Center")
pdf.add_five_cell_row(
cell1_text="Add 5 Cell Row - Cell 1 - Align Left",
cell2_text="Add 5 Cell Row - Cell 2 - Align Left",
cell3_text="Add 5 Cell Row - Cell 3 - Align Left",
cell4_text="Add 5 Cell Row - Cell 4 - Align Left",
cell5_text="Add 5 Cell Row - Cell 5 - Align Left",
cell1_align="L",
cell2_align="L",
cell3_align="L",
cell4_align="L",
cell5_align="L"
)
# Add 1 Cell Row - Align Right
print("Adding 1 Cell Row - Align Right")
pdf.add_one_cell_row("Add 1 Cell Row - Align Right", align="R")
# Add 2 Cell Row - Align Right
print("Adding 2 Cell Row - Align Right")
pdf.add_two_cell_row(
cell1_text="Add 2 Cell Row - Cell 1 - Align Right",
cell2_text="Add 2 Cell Row - Cell 2 - Align Right",
cell1_align="R",
cell2_align="R"
)
# Add 3 Cell Row - Align Right
print("Adding 3 Cell Row - Align Right")
pdf.add_three_cell_row(
cell1_text="Add 3 Cell Row - Cell 1 - Align Right",
cell2_text="Add 3 Cell Row - Cell 2 - Align Right",
cell3_text="Add 3 Cell Row - Cell 3 - Align Right",
cell1_align="R",
cell2_align="R",
cell3_align="R"
)
# Add 4 Cell Row - Align Right
print("Adding 4 Cell Row - Align Right")
pdf.add_four_cell_row(
cell1_text="Add 4 Cell Row - Cell 1 - Align Right",
cell2_text="Add 4 Cell Row - Cell 2 - Align Right",
cell3_text="Add 4 Cell Row - Cell 3 - Align Right",
cell4_text="Add 4 Cell Row - Cell 4 - Align Right",
cell1_align="R",
cell2_align="R",
cell3_align="R",
cell4_align="R"
)
# Add 5 Cell Row - Align Right
print("Adding 5 Cell Row - Align Center")
pdf.add_five_cell_row(
cell1_text="Add 5 Cell Row - Cell 1 - Align Right",
cell2_text="Add 5 Cell Row - Cell 2 - Align Right",
cell3_text="Add 5 Cell Row - Cell 3 - Align Right",
cell4_text="Add 5 Cell Row - Cell 4 - Align Right",
cell5_text="Add 5 Cell Row - Cell 5 - Align Right",
cell1_align="R",
cell2_align="R",
cell3_align="R",
cell4_align="R",
cell5_align="R"
)
# Add Empty Row
print("Adding empty row")
pdf.add_empty_row()
# Creating row without border
print("Creating row without border")
pdf.add_one_cell_row("Creating row without border", border=0)
# Create row without border and with fill
print("Creating row without border and with fill")
pdf.add_one_cell_row(
"Creating row without border and with fill",
border=0,
fill=1,
r=195,
g=223,
b=236)
# Create 3 row with border, and first cell is filled
print("Creating 3 row with border, and first cell is filled")
pdf.add_three_cell_row(
cell1_text="Creating 3 row with border, and first cell is filled",
cell2_text="Creating 3 row with border, and first cell is filled",
cell3_text="Creating 3 row with border, and first cell is filled",
cell1_fill=1,
r=195,
g=223,
b=236,
)
# Attempt to overfill page
print("Attempting to overfill page by adding 10 rows")
for i in range(1, 11):
pdf.add_one_cell_row(f"Add 1 Cell Row - Align Center - Row {i}")
# Change Fill Color
# Change Font
# Added 2 new pages
print("Adding new page")
pdf.add_page()
print("Adding 3 Cell Row - Align Center")
pdf.add_three_cell_row(
cell1_text="Add 3 Cell Row - Cell 1 - Align Center",
cell2_text="Add 3 Cell Row - Cell 2 - Align Center",
cell3_text="Add 3 Cell Row - Cell 3 - Align Center",
)
print("Adding new page")
pdf.add_page()
print("Adding 3 Cell Row - Align Center")
pdf.add_three_cell_row(
cell1_text="Add 3 Cell Row - Cell 1 - Align Center",
cell2_text="Add 3 Cell Row - Cell 2 - Align Center",
cell3_text="Add 3 Cell Row - Cell 3 - Align Center",
)
# Export PDF
print("Exporting PDF")
pdf.export("example.pdf")