Charset issue with UTF-8 characters
Fank opened this issue · comments
I tried following
// Logo
pdf.SetFont("Arial", "B", 21)
pdf.SetXY(2, 2)
pdf.Cell(40, 10, "KUEGNE+NAGEL")
// Consignee
pdf.SetXY(2, 10)
pdf.SetFont("Arial", "", 8)
pdf.Cell(10, 10, "Consignee")
pdf.SetXY(2, 14)
pdf.SetFont("Arial", "", 10)
pdf.Cell(10, 10, "Testemfänger")
pdf.SetXY(2, 18)
pdf.SetFont("Arial", "", 10)
pdf.Cell(10, 10, "Testempfänger Straße 1")
pdf.SetXY(2, 24)
pdf.SetFont("Arial", "B", 18)
pdf.Cell(10, 10, "DE 94315")
pdf.SetXY(2, 30)
pdf.SetFont("Arial", "", 10)
pdf.Cell(10, 10, "Straubing")
You will need to either fuss with code pages (see this example) or load a UTF-8 TrueType font (see this example).
Ok, but why doesn't it support utf-8 by default?
This is the first golang library where i had encoding issues by default.
Ok, but why doesn't it support utf-8 by default?
This package was ported from FPDF which itself does not support UTF-8. UTF-8 support in gofpdf was added earlier this year. Additional work will be needed to apply this support to the reader-embedded fonts. Use gopdf if you don't want to bother with code pages.
Thanks for the info and help, problem solved.