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.31k stars 777 forks source link

fix utf8 text wrapping #279

Closed seletskiy closed 5 years ago

seletskiy commented 5 years ago

UTF8 text splitted correctly by SplitText function in WriteAligned method:

https://github.com/jung-kurt/gofpdf/blob/3aaf0b1a66c0ab02d925917376898a5856061d59/fpdf.go#L2811

Then, lines of text are written via Write function, and if text is already wrapped by given width it will be printed using 'last chunk' case:

https://github.com/jung-kurt/gofpdf/blob/3aaf0b1a66c0ab02d925917376898a5856061d59/fpdf.go#L2747-L2754

But in this case, gofpdf does not move cursor to the next cell, which cause all text to be printed on the same line without actual wrapping.

This commit makes workaround for it by explicitly setting right margin to force automatic line break case:

https://github.com/jung-kurt/gofpdf/blob/3aaf0b1a66c0ab02d925917376898a5856061d59/fpdf.go#L2705-L2706

jung-kurt commented 5 years ago

Thanks, @seletskiy!

seletskiy commented 5 years ago

@jung-kurt By mistake I've pushed wrong commit, so please revert this PR and I will make a new one.

Code in this PR is wrong.