Pyfpdf euro Character in Python

188 Views Asked by At

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)"

    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, "€")
    pdf.set_font('times', '', 12)
    pdf.output('pdf_1.pdf').encode('utf-8')```
0

There are 0 best solutions below