jung-kurt / gofpdf

A PDF document generator with high level support for text, drawing and images
http://godoc.org/github.com/jung-kurt/gofpdf
MIT License
4.29k stars 772 forks source link

fix utf16 in bookmarks #310

Closed SuddenGunter closed 4 years ago

SuddenGunter commented 4 years ago

Fix for https://github.com/jung-kurt/gofpdf/issues/307

Tested on this code:

    pdf := gofpdf.New("P", "mm", "A5", "")
    pdf.AddUTF8Font("HAN NOM A", "", "hn.ttf")
    pdf.SetFont("HAN NOM A", "", 16)
    pdf.AddPage()
    pdf.Bookmark("1段落", 1, -1)
    pdf.Cell(0, 6, "2段落")
    pdf.Ln(50)
    pdf.AddPage()
    fileStr := example.Filename("Fpdf_Bookmark")
    err := pdf.OutputFileAndClose(fileStr)
    example.Summary(err, fileStr)
    // Output:
    // Successfully generated pdf/Fpdf_Bookmark.pdf

Result PDF: 1569709835_0130_29092019_519x248

I was unable to find ttf version of the font in original issue so used different one, but I think it won't be a problem.

jung-kurt commented 4 years ago

Many thanks, @SuddenGunter!