Closed Guoozz closed 4 years ago
Thanks for the report, @Guoozz. If I remember correctly, those bookmark names are UTF-16 encoded. I don't think the recent UTF-8 work included any conversion routines to UTF-16. I will look into this and hope others do too.
The same problem occurs when entering Korean bookmarks.
func (r *Report) writeReport(pdf *gofpdf.Fpdf) error {
pdf.AddPage()
pdf.SetFont(HangulFont, "", 16)
pdf.Bookmark("1. 커버", 0, 0)
pdf.Cell(0, 6, "1. 커버")
@jung-kurt can I take it, is this a good first issue? I've not so much experience in Go
can I take it
Absolutely! Thanks or your interest, @SuddenGunter!
is this a good first issue?
Possibly -- I haven't looked into to know how difficult it might be. You will want to study utf8toutf16()
and .isCurrentUTF8
. My assumption here is that the bookmark problem occurs only with UTF-8 fonts.
If this problem turns out to be too frustrating but you are still interested in tackling something else, let me know and I'll scan the list for another issue.
I was able to reproduce it locally. It took some time to install Chinese fonts and get it to work. Will debug it and try to fix, possibly this weekend. UPD: https://github.com/jung-kurt/gofpdf/blob/master/fpdf.go#L2389 - here you have checks that do this fix from utf8 to utf16. The fix itself occurs on https://github.com/jung-kurt/gofpdf/blob/master/fpdf.go#L2419. But this formatting happens only for content of pdf, I cannot find if you format bookmark text the same way with checks and conversions
UPD2: see pr https://github.com/jung-kurt/gofpdf/pull/310
@SuddenGunter: Thanks for your work on this and for your updates!
@Guoozz @devplayg plz check latest version: was issue resolved for you?
@SuddenGunter the problem has resolved, thanks very much.
@jung-kurt can we close this issue now?
can we close this issue now?
Yes, you may have the honors. Thanks again, @SuddenGunter.
Yes, you may have the honors
but I don't have required rights in repo :) do it
I want to generate PDF that contains bookmark outlines, but the Chinese characters are corrupted.
Test Code
Generated PDF