This was not corrected by the "Bug #3158193 "Endless loop in writeHTML" was fixed" in 5.9.043 but it sounds like the same bug. This bug occurs when an img tag with a width attr straddles the right margin, causing a new line to be generated. As was described in the referenced bug, the loop is caused by the line:
--$key;
which is commented as
// go back to evaluate this line break
In the attached sample file, the "-$key" goes back to the only other tag on the line (the text) and loops back to the same logic - the text fits but shoves the image into the margin.
Why is the -$key even there? I don't pretend to understand the code but commenting that line out causes everything to function correctly. What am I breaking by getting rid of the "-$key"?
writeHTMLCell loop bug
OK. Fixed on TCPDF 5.9.044.
I've also fixed other image-related problems.
Thank you for fixing this so quickly. I am still curious about what problems the line:
// go back to evaluate this line break
--$key;
is in there to fix. It seems like it is enough to just put the img onto a new line. Why go back?