D
Deleted member 1247054
Guest
It seems that its not possible to write the euro symbol with pyfpdf. I really need to add the euro symbol to my report as I'm working with prices.
I'm getting the following error and I don't know how to solve it :
"UnicodeEncodeError: 'latin-1' codec can't encode character '\u20ac' in position 201: ordinal not in range(256)"
I'm getting the following error and I don't know how to solve it :
"UnicodeEncodeError: 'latin-1' codec can't encode character '\u20ac' in position 201: ordinal not in range(256)"
Python:
prix = "250.434€"
pdf = FPDF('P', 'mm', 'Letter')
# Add a page
pdf.add_page()
# specify font
# fonts ('times', 'courier', 'helvetica', 'symbol', 'zpfdingbats')
# 'B' (bold), 'U' (underline), 'I' (italics), '' (regular), combination (i.e., ('BU'))
pdf.set_font('helvetica', 'BIU', 16)
pdf.set_text_color(220, 50, 50)
# Add text
# w = width
# h = height
# txt = your text
# ln (0 False; 1 True - move cursor down to next line)
# border (0 False; 1 True - add border around cell)
pdf.cell(120, 100, 'Hello World!', ln=True, border=True)
pdf.cell(120, 100, prix)
pdf.set_font('times', '', 12)
pdf.output('pdf_1.pdf')