Search code examples
phpdompdf

dompdf does wrong calculation for line breaks breaking words


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.


Solution

  • 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');