gofpdf
gofpdf copied to clipboard
Charset weirdness despite using core PDF fonts
Steps to reproduce:
-
create a new
*gofpdf.FPDF
:pdf := gofpdf.New("P", "pt", "Letter", "")
-
set the font to Courier 12:
pdf.SetFont("courier", "", 12)
-
write a bullet character,
•
(U+2022):pdf.Write("•", 12)
-
write the PDF to a file:
f, err := os.Create("/tmp/output.pdf") if err != nil { t.Fatal(err) } defer f.Close() pdf.Output(f)
Expected:
- Bullet is written to rendered PDF
Actual:
- Rendered PDF shows
•
Discussion:
I admit, I haven't dug deep enough to quite get the state of GoFPF UTF-8 support. My first thought was that I needed to add UTF-8 font, but according to the AddUTF8Font docs,
It is not necessary to call this function for the core PDF fonts (courier, helvetica, times, zapfdingbats).
Regardless, is that the workaround? Or is there a workaround? Are we currently limited to certain code pages?