go-pdf / fpdf

A PDF document generator with high level support for text, drawing and images
MIT License
563 stars 47 forks source link

Calling SplitText on Japanese/Chinese characters removes some of them. #80

Open daksh-sehgal opened 4 months ago

daksh-sehgal commented 4 months ago

If you call splitText on a string such as "参照番号", it may have the last character removed for some widths. i.e. SplitText("参照番号", 18.46) returns ["参照番"].

Kohirus commented 3 months ago

I had the same problem:

pdf := fpdf.New("P", "mm", "A4", "./fonts")
pdf.AddUTF8Font("myfont", "", "font.ttf")
pdf.SetFont("myfont", "", 14)
pageWidth, _ := pdf.GetPageSize()
width := pageWidth - 30
pdf.MultiCell(width, 8, "该视频中共检测出 2 项格式问题,此类问题可能会导致:可能影响视频播放,影响播放体验", fpdf.BorderNone, fpdf.AlignLeft, false)
image