FPDF tick and cross

I am trying to place a tick (aka check mark) or cross in a pdf

What I’ve tried and what’s not working:
I’m using FPDF to output a precisely formatted pdf document. Part of the output is a “y” or an “n” (depending on the choices made by users) which I want to output as a tick ( :heavy_check_mark: ) or a cross ( ✕ ) characters 10004 and 10005 in most fonts. I try to print these characters using FPDF2 and get this error:
UnicodeEncodeError: ‘latin-1’ codec can’t encode character ‘\u2714’ in position 1279: ordinal not in range(256).
How can I get FPDF to show characters beyond 256?

Code Sample:
pdf.text(21 + 8 * dictnum, ypos+16, chr(10004))```

Clone link:
share a copy of your app

I found a simple solution myself which I reproduce here in case anyone else wants to achieve something similar.
First I add the Zapf Dingbats font with
pdf.set_font(“ZapfDingbats”, style=“”, size=8)
then I can print a tick with
pdf.text(21 + 8 * dictnum, ypos+16, chr(52))
or a cross with
pdf.text(21 + 8 * dictnum, ypos+16, chr(54))

2 Likes