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

empty symbol #294

Open hyzgh opened 4 years ago

hyzgh commented 4 years ago

I use MultiCell to generate a pdf, it works well when there is not missing symbols. But when there are some missing symbols, it will generate a text with some empty, please see the picture in the following.

pdf := gofpdf.New("P", "mm", "A4", "font/")
pdf.AddUTF8Font("stsong", "", "stsong.ttf")
pdf.SetFont("stsong", "", 14)
pdf.AddPage()
txtStr, err := ioutil.ReadFile(fileName)

pdf.MultiCell(0, 7, string(txtStr), "", "", false)
if pdf.Err() {
    fmt.Println(pdf.Error())
    continue
}
pdf.Ln(-1)

err = pdf.OutputFileAndClose(fileName + ".pdf")
if err != nil {
    panic(err)
}

txt: image

pdf: image

I would like to know whether there is a way to know the text will be empty when generating the pdf.

jung-kurt commented 4 years ago

Thanks for report, @hyzgh. Can you provide the text file referenced by filename as a file rather than a PNG image? This will assist in solving this.

hyzgh commented 4 years ago

@jung-kurt Here it is. 10.txt

ArtemKor commented 4 years ago

Are you sure the font stsong.ttf contains malagasy glyphs?

hyzgh commented 4 years ago

@ArtemKor malagasy glyphs?

ArtemKor commented 4 years ago

@hyzgh Sorry, I made a mistake in defining the alphabet. But the question remains the same: Are you sure the font stsong.ttf contains Tibetan glyphs?

hyzgh commented 4 years ago

@ArtemKor No, it doesn't. I need to transfer some .txt files to .pdf files, but it seems that I could only check .pdf on my own to confirm whether there is some failing glyphs. And I would like to know whether there is a way to know the text will be empty by the code.