dompdf does wrong calculation for line breaks breaking words

故事扮演 提交于 2019-12-25 05:20:24

问题


I'm using dompdf 0.5.2 and having the problem that when there is an accent on a line, the first character from the next line is moved into it, like:

This is a first line with áccent. T
his is a second line.

Notice the T at the end of the first line, it belongs to the second. It happens both with a default and a custom loaded font. Also tried with UTF-8 and ISO-8859-1 encodings.


回答1:


Another solution that worked for me is using the wordwrap PHP function on your text/string .




回答2:


If someone have the same issue with the 0.7.0-beta version, the solution is adding the following line to the file src/Dompdf/FrameReflower/Text.php on line 272 (just before if ($split == 0) {):

$split = mb_strlen(mb_substr($this->_frame->get_text(), 0, $split), 'UTF-8');



回答3:


The solution that worked, taken from here, is adding the following line of code to the dompdf file include/text_frame_reflower.cls.php after line 246:

$split = mb_strlen(mb_substr($this->_frame->get_text(), 0, $split), 'UTF-8');


来源:https://stackoverflow.com/questions/12410899/dompdf-does-wrong-calculation-for-line-breaks-breaking-words

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!