go-pdf/fpdf

Euro Icon for CellFormat

Closed this issue · 2 comments

Hello! I am trying to use the euro icon or \u20ac in CellFormat, however, I am not getting any success.

After passing pdf.CellFormat(w[4], 8, "€[1500,00]", "", 0, "R", false, 0, "") I am getting:
image

Same happens if I put instead of the , \u20ac. Can I get some guidance on this please?

UTF-8 handling is a bit cumbersome.
see:
https://pkg.go.dev/github.com/go-pdf/fpdf#example-Fpdf.CellFormat-Codepage

e.g.:

package main

import (
	"log"

	"github.com/go-pdf/fpdf"
)

func main() {
	pdf := fpdf.New(fpdf.OrientationPortrait, "mm", "A4", "")
	pdf.AddPage()
	pdf.SetFont("Arial", "B", 16)
	tr := pdf.UnicodeTranslatorFromDescriptor("")
	pdf.Cell(40, 10, tr("Hello World! €"))
	err := pdf.OutputFileAndClose("out.pdf")
	if err != nil {
		log.Fatal(err)
	}
}

(closing. feel free to reopen if that didn't answer your question)