-
Hi, First of all, thanks for including table() in py-fpdf. I am trying to make a table where only a column will contain the italic text, the text in the rest of the columns will be in the normal font. It would be a great help if you could let me know how to solve this. Thank you in advance. Best |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @aritramhp Welcome to the It's totally fine to ask such questions there, I would just recommend to provide some code with your message, to share what you tried so far 🙂 Anyway, could you try this code and tell if that fits your needs? from fpdf import FontFace, FPDF
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", "Saint-Mahturin-sur-Loire"),
)
ITALICS = FontFace(emphasis="ITALICS")
INDEX_OF_COLUMN_IN_ITALICS = 2
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 i, datum in enumerate(data_row):
row.cell(datum, style=ITALICS if i == INDEX_OF_COLUMN_IN_ITALICS else None)
pdf.output("discussion_1070.pdf") |
Beta Was this translation helpful? Give feedback.
Hi @aritramhp
Welcome to the
fpdf2
community 😊It's totally fine to ask such questions there, I would just recommend to provide some code with your message, to share what you tried so far 🙂
Anyway, could you try this code and tell if that fits your needs?