forked from reingart/pyfpdf
-
Notifications
You must be signed in to change notification settings - Fork 259
/
test_table.py
675 lines (581 loc) · 20.7 KB
/
test_table.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
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
import logging
from pathlib import Path
import pytest
from fpdf import FPDF, FPDFException
from fpdf.drawing import DeviceRGB
from fpdf.fonts import FontFace
from test.conftest import assert_pdf_equal, LOREM_IPSUM
HERE = Path(__file__).resolve().parent
TABLE_DATA = (
("First name", "Last name", "Age", "City"),
("Jules", "Smith", "34", "San Juan"),
("Mary", "Ramos", "45", "Orlando"),
("Carlson", "Banks", "19", "Los Angeles"),
("Lucas", "Cimon", "31", "Angers"),
)
MULTILINE_TABLE_DATA = (
("Extract", "Text length"),
(LOREM_IPSUM[:200], str(len(LOREM_IPSUM[:200]))),
(LOREM_IPSUM[200:400], str(len(LOREM_IPSUM[200:400]))),
(LOREM_IPSUM[400:600], str(len(LOREM_IPSUM[400:600]))),
(LOREM_IPSUM[600:800], str(len(LOREM_IPSUM[600:800]))),
(LOREM_IPSUM[800:1000], str(len(LOREM_IPSUM[800:1000]))),
(LOREM_IPSUM[1000:1200], str(len(LOREM_IPSUM[1000:1200]))),
)
MULTI_HEADING_TABLE_DATA = (
("Fruits", "Dairy"),
("Apple", "Banana", "Cherry", "Cheese", "Milk", "Yogurt"),
("1", "2", "3", "4", "5", "6"),
("2", "3", "4", "5", "6", "7"),
("3", "4", "5", "6", "7", "8"),
)
def test_table_simple(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table() as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_simple.pdf", tmp_path)
def test_table_with_no_row():
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table():
pass
def test_table_with_no_column():
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table() as table:
for _ in TABLE_DATA:
table.row()
def test_table_with_syntactic_sugar(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(TABLE_DATA):
pass
assert_pdf_equal(pdf, HERE / "table_simple.pdf", tmp_path)
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table() as table:
table.row(TABLE_DATA[0])
table.row(TABLE_DATA[1])
table.row(TABLE_DATA[2])
table.row(TABLE_DATA[3])
table.row(TABLE_DATA[4])
assert_pdf_equal(pdf, HERE / "table_simple.pdf", tmp_path)
def test_table_with_fixed_col_width(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(col_widths=pdf.epw / 5) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_fixed_col_width.pdf", tmp_path)
def test_table_with_varying_col_widths(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(col_widths=(30, 30, 10, 30)) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_varying_col_widths.pdf", tmp_path)
def test_table_with_invalid_col_widths():
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pytest.raises(ValueError):
with pdf.table(col_widths=(20, 30, 50)) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
def test_table_with_fixed_row_height(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(line_height=2.5 * pdf.font_size) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_fixed_row_height.pdf", tmp_path)
def test_table_with_multiline_cells(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table() as table:
for data_row in MULTILINE_TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert pdf.pages_count == 2
assert_pdf_equal(pdf, HERE / "table_with_multiline_cells.pdf", tmp_path)
def test_table_with_multiline_cells_and_fixed_row_height(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(line_height=2.5 * pdf.font_size) as table:
for data_row in MULTILINE_TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert pdf.pages_count == 2
assert_pdf_equal(
pdf, HERE / "table_with_multiline_cells_and_fixed_row_height.pdf", tmp_path
)
def test_table_with_fixed_width(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(width=150) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_fixed_width.pdf", tmp_path)
def test_table_with_invalid_width():
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pytest.raises(ValueError):
with pdf.table(width=200) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
def test_table_without_headings(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(first_row_as_headings=False) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_without_headings.pdf", tmp_path)
def test_table_with_multiline_cells_and_without_headings(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(first_row_as_headings=False) as table:
for data_row in MULTILINE_TABLE_DATA + MULTILINE_TABLE_DATA[1:]:
row = table.row()
for datum in data_row:
row.cell(datum)
assert pdf.pages_count == 4
assert_pdf_equal(
pdf,
HERE / "table_with_multiline_cells_and_without_headings.pdf",
tmp_path,
)
def test_table_with_headings_styled(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
blue = DeviceRGB(r=0, g=0, b=1)
grey = 128
headings_style = FontFace(emphasis="ITALICS", color=blue, fill_color=grey)
with pdf.table(headings_style=headings_style) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_headings_styled.pdf", tmp_path)
def test_table_with_multiline_cells_and_split_over_3_pages(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table() as table:
for data_row in MULTILINE_TABLE_DATA + MULTILINE_TABLE_DATA[1:]:
row = table.row()
for datum in data_row:
row.cell(datum)
assert pdf.pages_count == 4
assert_pdf_equal(
pdf, HERE / "table_with_multiline_cells_and_split_over_3_pages.pdf", tmp_path
)
def test_table_with_cell_fill(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
greyscale = 200
with pdf.table(cell_fill_color=greyscale, cell_fill_mode="ROWS") as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
pdf.ln()
lightblue = (173, 216, 230)
with pdf.table(cell_fill_color=lightblue, cell_fill_mode="COLUMNS") as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_cell_fill.pdf", tmp_path)
def test_table_with_internal_layout(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(borders_layout="INTERNAL") as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_internal_layout.pdf", tmp_path)
def test_table_with_minimal_layout(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
pdf.set_draw_color(100) # dark grey
pdf.set_line_width(1)
with pdf.table(borders_layout="MINIMAL") as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_minimal_layout.pdf", tmp_path)
def test_table_with_single_top_line_layout(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
pdf.set_draw_color(50) # very dark grey
pdf.set_line_width(0.5)
with pdf.table(borders_layout="SINGLE_TOP_LINE") as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_single_top_line_layout.pdf", tmp_path)
def test_table_with_single_top_line_layout_and_page_break(tmp_path): # PR #912
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
pdf.set_draw_color(50) # very dark grey
pdf.set_line_width(0.5)
data = list(MULTILINE_TABLE_DATA)
# Reducing the text content on the 3rd line
# so that there is an even number of rows on the 1st page:
data[2] = (data[2][0][:-30], data[2][1])
with pdf.table(
borders_layout="SINGLE_TOP_LINE", cell_fill_color=230, cell_fill_mode="ROWS"
) as table:
for data_row in data:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(
pdf, HERE / "table_with_single_top_line_layout_and_page_break.pdf", tmp_path
)
def test_table_align(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(text_align="CENTER") as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
pdf.ln()
with pdf.table(text_align=("CENTER", "CENTER", "RIGHT", "LEFT")) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_align.pdf", tmp_path)
def test_table_capture_font_settings(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
black = (0, 0, 0)
lightblue = (173, 216, 230)
with pdf.table(headings_style=FontFace(color=black, emphasis="B")) as table:
for row_num, data_row in enumerate(TABLE_DATA):
with pdf.local_context(text_color=lightblue):
row = table.row()
for col_num, datum in enumerate(data_row):
font_style = FontFace(
emphasis="I" if row_num > 0 and col_num == 0 else None
)
row.cell(datum, style=font_style)
assert_pdf_equal(pdf, HERE / "table_capture_font_settings.pdf", tmp_path)
def test_table_with_ttf_font(caplog, tmp_path): # issue 749
caplog.set_level(logging.ERROR) # hides fonttool warnings
pdf = FPDF()
pdf.add_page()
pdf.add_font(fname=HERE / "../fonts/cmss12.ttf")
pdf.set_font("cmss12", size=16)
with pdf.table(first_row_as_headings=False) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_ttf_font.pdf", tmp_path)
def test_table_with_ttf_font_and_headings(caplog, tmp_path):
caplog.set_level(logging.ERROR) # hides fonttool warnings
pdf = FPDF()
pdf.add_page()
pdf.add_font("Roboto", fname=HERE / "../fonts/Roboto-Regular.ttf")
pdf.add_font("Roboto", style="BI", fname=HERE / "../fonts/Roboto-BoldItalic.TTF")
pdf.set_font("Roboto", size=16)
with pdf.table(headings_style=FontFace(emphasis="IB")) as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert_pdf_equal(pdf, HERE / "table_with_ttf_font_and_headings.pdf", tmp_path)
def test_table_with_ttf_font_and_headings_but_missing_bold_font():
pdf = FPDF()
pdf.add_page()
pdf.add_font("Quicksand", fname=HERE / "../fonts/Quicksand-Regular.otf")
pdf.set_font("Quicksand", size=16)
with pytest.raises(FPDFException) as error:
with pdf.table() as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum)
assert (
str(error.value)
== "Using font emphasis 'B' in table headings require the corresponding font style to be added using add_font()"
)
def test_table_with_cell_overflow(tmp_path):
pdf = FPDF()
pdf.set_font("Times", size=30)
pdf.add_page()
with pdf.table(width=pdf.epw / 2, col_widths=(1, 2, 1)) as table:
row = table.row()
row.cell("left")
row.cell("center")
row.cell("right") # triggers header cell overflow on last column
row = table.row()
row.cell("A1")
row.cell("A2")
row.cell("A33333333") # triggers cell overflow on last column
row = table.row()
row.cell("B1")
row.cell("B2")
row.cell("B3")
assert_pdf_equal(pdf, HERE / "table_with_cell_overflow.pdf", tmp_path)
def test_table_with_gutter(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=16)
with pdf.table(TABLE_DATA, gutter_height=3, gutter_width=3):
pass
pdf.ln(10)
with pdf.table(
TABLE_DATA, borders_layout="SINGLE_TOP_LINE", gutter_height=3, gutter_width=3
):
pass
assert_pdf_equal(pdf, HERE / "table_with_gutter.pdf", tmp_path)
def test_table_with_colspan_and_gutter(tmp_path): # issue 808
pdf = FPDF()
pdf.set_font("Times", size=30)
pdf.add_page()
with pdf.table(col_widths=(1, 2, 1, 1), gutter_height=5, gutter_width=5) as table:
row = table.row()
row.cell("0")
row.cell("1")
row.cell("2")
row.cell("3")
row = table.row()
row.cell("A1")
row.cell("A2", colspan=2)
row.cell("A3")
row = table.row()
row.cell("B1", colspan=2)
row.cell("B2")
row.cell("B3")
assert_pdf_equal(pdf, HERE / "table_with_colspan_and_gutter.pdf", tmp_path)
def test_table_with_capitalized_font_family_and_emphasis(): # issue 828
pdf = FPDF()
pdf.add_page()
with pdf.table(
TABLE_DATA, headings_style=FontFace(family="Helvetica", emphasis="ITALICS")
):
pass
def test_table_with_no_headers_nor_horizontal_lines(tmp_path): # discussion 924
pdf = FPDF()
pdf.set_font("Helvetica")
pdf.add_page()
with pdf.table(
TABLE_DATA,
cell_fill_color=200,
cell_fill_mode="ROWS",
text_align="LEFT",
borders_layout="NO_HORIZONTAL_LINES",
first_row_as_headings=False,
):
pass
assert_pdf_equal(
pdf, HERE / "table_with_no_headers_nor_horizontal_lines.pdf", tmp_path
)
def test_table_page_break_with_table_in_header(tmp_path): # issue 943
class PDF(FPDF):
def header(self):
with self.table() as t:
r = t.row()
r.cell("headertext")
pdf = PDF()
pdf.set_font("helvetica", "B", 8)
pdf.add_page()
with pdf.table() as table:
for _ in range(1, 15):
for data_row in TABLE_DATA:
table.row(data_row)
assert_pdf_equal(pdf, HERE / "table_page_break_with_table_in_header.pdf", tmp_path)
def test_table_with_multiple_headings_and_pagebreak(tmp_path):
pdf = FPDF()
pdf.set_font("Times", size=12)
pdf.add_page()
pdf.set_y(240)
with pdf.table(
num_heading_rows=2,
) as table:
for j, rowdata in enumerate(MULTI_HEADING_TABLE_DATA):
if j == 0:
# row with colspan
row = table.row()
for cell in rowdata:
row.cell(text=cell, colspan=3)
else:
table.row(cells=rowdata)
assert_pdf_equal(
pdf,
HERE / "table_with_multiple_headings_and_pagebreak.pdf",
tmp_path,
)
def test_table_num_heading_rows_and_first_row_as_headings():
pdf = FPDF()
pdf.set_font("Times", size=12)
pdf.add_page()
with pytest.raises(ValueError):
with pdf.table(TABLE_DATA, first_row_as_headings=True, num_heading_rows=0):
pass
with pytest.raises(ValueError):
with pdf.table(TABLE_DATA, first_row_as_headings=False, num_heading_rows=2):
pass
def test_table_with_multiple_headings_and_no_horizontal_lines(tmp_path):
pdf = FPDF()
pdf.set_font("Times", size=12)
pdf.add_page()
with pdf.table(
borders_layout="NO_HORIZONTAL_LINES",
num_heading_rows=2,
) as table:
for j, rowdata in enumerate(MULTI_HEADING_TABLE_DATA):
if j == 0:
# row with colspan
row = table.row()
for cell in rowdata:
row.cell(text=cell, colspan=3)
else:
table.row(cells=rowdata)
assert_pdf_equal(
pdf,
HERE / "table_with_multiple_headings_and_no_horizontal_lines.pdf",
tmp_path,
)
def test_table_with_minimal_layout_and_multiple_headings(tmp_path):
pdf = FPDF()
pdf.set_font("Times", size=12)
pdf.add_page()
pdf.set_draw_color(100) # dark grey
pdf.set_line_width(1)
with pdf.table(
borders_layout="MINIMAL",
num_heading_rows=2,
) as table:
for j, rowdata in enumerate(MULTI_HEADING_TABLE_DATA):
if j == 0:
# row with colspan
row = table.row()
for cell in rowdata:
row.cell(text=cell, colspan=3)
else:
table.row(cells=rowdata)
assert_pdf_equal(
pdf,
HERE / "table_with_minimal_layout_and_multiple_headings.pdf",
tmp_path,
)
def test_table_with_single_top_line_layout_and_multiple_headings(tmp_path):
pdf = FPDF()
pdf.set_font("Times", size=12)
pdf.add_page()
with pdf.table(
borders_layout="SINGLE_TOP_LINE",
num_heading_rows=2,
) as table:
for j, rowdata in enumerate(MULTI_HEADING_TABLE_DATA):
if j == 0:
# row with colspan
row = table.row()
for cell in rowdata:
row.cell(text=cell, colspan=3)
else:
table.row(cells=rowdata)
assert_pdf_equal(
pdf,
HERE / "table_with_single_top_line_layout_and_multiple_headings.pdf",
tmp_path,
)
def test_table_with_no_horizontal_lines_layout(tmp_path):
pdf = FPDF()
pdf.set_font("Times", size=12)
pdf.add_page()
with pdf.table(
TABLE_DATA,
borders_layout="NO_HORIZONTAL_LINES",
num_heading_rows=1,
):
pass
assert_pdf_equal(
pdf,
HERE / "table_with_no_horizontal_lines_layout.pdf",
tmp_path,
)
def test_table_with_heading_style_overrides(tmp_path):
pdf = FPDF()
pdf.set_font(family="helvetica", size=10)
pdf.add_page()
with pdf.table(
headings_style=FontFace(emphasis="B", size_pt=18), num_heading_rows=2
) as table:
# should be Helvetica bold size 18
table.row().cell("Big Heading", colspan=3)
second_header = table.row()
# should be Helvetica bold size 14:
second_header_style_1 = FontFace(size_pt=14)
second_header.cell("First", style=second_header_style_1)
# should be Times italic size 14
second_header_style_2_3 = FontFace(family="times", emphasis="I", size_pt=14)
second_header.cell("Second", style=second_header_style_2_3)
second_header.cell("Third", style=second_header_style_2_3)
# should be helvetica normal size 10
table.row(("Some", "Normal", "Data"))
assert_pdf_equal(pdf, HERE / "table_with_heading_style_overrides.pdf", tmp_path)
def test_table_with_set_fill_color(tmp_path): # issue 963
pdf = FPDF()
pdf.set_font("helvetica", size=10)
pdf.add_page()
with pdf.table(first_row_as_headings=False) as table:
row = table.row()
pdf.set_fill_color(200)
pdf.set_fill_color(200, 200, 200)
row.cell("Hello")
assert_pdf_equal(
pdf,
HERE / "table_with_set_fill_color.pdf",
tmp_path,
)