OK, new code, with input as countries.txt
:
sssssssssssssssssss,mmmmmmmmmmmmmmmm,mmmmmmmmmmmmmmmmmmmmmmmsss
jjjjjjj,kkkkkkkkkkk,lllllllllllll
hhhhhhhhhhhh,ggggggggggggggggggg,ooooooooooooo
my code :
import csv
from fpdf import FPDF, fpdf
with open("countries.txt", encoding="utf8") as csv_file:
data = list(csv.reader(csv_file, delimiter=","))
pdf = FPDF()
pdf.set_font("helvetica", size=14)
pdf.add_page()
pdf.set_draw_color(255, 0, 0)
pdf.set_line_width(0.3)
with pdf.table(
# borders_layout="NO_HORIZONTAL_LINES",
cell_fill_color=(255, 235, 0),
# cell_fill_mode= 'ALL',
cell_fill_mode= 'NONE',
first_row_as_headings = False,
col_widths=(42, 39, 35, 42),
line_height=6,
text_align=("LEFT", "CENTER", "RIGHT", "RIGHT"),
width=160,
) as table:
for data_row in data:
row = table.row()
for i, _data in enumerate(data_row):
_color = (224, 235, 255) if i % 2 == 0 else None
# row.cell(_data, fill=_color) ### ----> TypeError: cell() got an unexpected keyword argument 'fill'
row.cell(_data, style = fpdf.FontFace(fill_color = _color))
pdf.output("tuto5.pdf")
output with cell_fill_mode= 'NONE',
:

output with cell_fill_mode= 'ALL',
:
