@@ -26,6 +26,7 @@ def __init__(self, type_: str, max_number: int, question_count: int):
26
26
self .large_font_size = 30
27
27
self .size = 21
28
28
self .tiny_pad_size = 2
29
+ self .middle_pad_size = 6
29
30
self .pad_size = 10
30
31
self .large_pad_size = 30
31
32
self .num_x_cell = 4
@@ -99,7 +100,10 @@ def make_question_page(self, data: List[QuestionInfo]):
99
100
total_pages = len (problems_per_page )
100
101
for page in range (total_pages ):
101
102
self .pdf .add_page (orientation = 'L' )
102
- if problems_per_page [page ] < self .num_x_cell :
103
+
104
+ if page == 0 :
105
+ self .print_header_section ()
106
+ elif problems_per_page [page ] < self .num_x_cell :
103
107
self .print_question_row (data , page * page_area , problems_per_page [page ])
104
108
else :
105
109
problems_per_row = self .split_arr (problems_per_page [page ], self .num_x_cell )
@@ -118,9 +122,9 @@ def split_arr(self, x: int, y: int):
118
122
119
123
return [y ] * quotient
120
124
121
- def print_top_row (self , question_num : str ):
125
+ def print_top_row (self , question_num : str , font_size : int = 15 ):
122
126
"""Helper function to print first character row of a question row"""
123
- self .pdf .set_font (self .font_1 , size = self . middle_font_size )
127
+ self .pdf .set_font (self .font_1 , size = font_size )
124
128
self .pdf .cell (self .pad_size , self .pad_size , txt = question_num , border = 'LT' , align = 'C' )
125
129
self .pdf .cell (self .size , self .pad_size , border = 'T' )
126
130
self .pdf .cell (self .size , self .pad_size , border = 'T' )
@@ -173,6 +177,14 @@ def print_bottom_row_division(self):
173
177
self .pdf .cell (self .size , self .size , border = 'B' )
174
178
self .pdf .cell (self .pad_size , self .size , border = 'BR' )
175
179
180
+ def print_header_section_bottom_row (self ):
181
+ """Helper function to print bottom row of header section"""
182
+ self .pdf .set_font (self .font_2 , size = self .tiny_pad_size )
183
+ self .pdf .cell (self .pad_size , self .pad_size , border = 'LB' , align = 'C' )
184
+ self .pdf .cell (self .size , self .pad_size , border = 'B' , align = 'C' )
185
+ self .pdf .cell (self .size , self .pad_size , border = 'B' , align = 'C' )
186
+ self .pdf .cell (self .pad_size , self .pad_size , border = 'BR' , align = 'C' )
187
+
176
188
def print_edge_vertical_separator (self ):
177
189
"""Print space between question for the top or bottom row"""
178
190
self .pdf .cell (self .pad_size , self .pad_size )
@@ -186,6 +198,29 @@ def print_horizontal_separator(self):
186
198
self .pdf .cell (self .size , self .size )
187
199
self .pdf .ln ()
188
200
201
+ def print_header_section (self ):
202
+ self .print_top_row (question_num = 'Date' , font_size = self .small_font_size )
203
+ self .print_edge_vertical_separator ()
204
+
205
+ self .print_top_row (question_num = 'Name' , font_size = self .small_font_size )
206
+ self .print_edge_vertical_separator ()
207
+
208
+ self .print_top_row (question_num = 'Score' , font_size = self .small_font_size )
209
+ self .print_edge_vertical_separator ()
210
+
211
+ self .print_top_row (question_num = '' )
212
+ self .print_edge_vertical_separator ()
213
+ self .pdf .ln ()
214
+
215
+ for _ in range (self .num_x_cell ):
216
+ self .print_header_section_bottom_row ()
217
+ self .print_edge_vertical_separator ()
218
+
219
+ self .pdf .ln ()
220
+
221
+ self .print_horizontal_separator (dimension = self .tiny_pad_size )
222
+
223
+
189
224
def print_question_row (self , data , offset , num_problems ):
190
225
"""Print a single row of questions (total question in a row is set by num_x_cell)"""
191
226
for x in range (0 , num_problems ):
0 commit comments