Menu

#970 WriteHTML TD tag with space before text issue

v1.0_(example)
closed
nobody
None
1
2014-09-05
2014-09-04
Liam Vans
No

Try the following piece of HTML with the WriteHTML function, result is that the text that has a space in front if it, is not rendered in the PDF, while the text that has no leading space, does appear.

This text is visible This text is not!

Discussion

  • Liam Vans

    Liam Vans - 2014-09-04

    Edit; escaped the HTML

    <table>
    <tr>
    <td>This text is visible</td>
    <td> This text is not! (mind the leading space)</td>
    </tr>
    </table>

     

    Last edit: Liam Vans 2014-09-04
  • Robert Johnson

    Robert Johnson - 2014-09-05

    I have experienced an issue like this, but it was not the fault of TCPDF. Some HTML gets written with a UTF-8 hard space character, which TCPDF rejects (whether that's right or wrong I don't know). TinyMCE definitely writes hard spaces into the HTML it generates when it encounters "&nbsp;"...

    You can do something like this to convert UTF-8 hard spaces to soft spaces before sending the HTML to TCPDF:

    $text = str_replace("\xC2\xA0", ' ', $text);
    
     
  • Nicola Asuni

    Nicola Asuni - 2014-09-05

    As indicated by Robert Johnson this seems to be a coding issue.
    You must be sure that the HTML code is properly encoded and eventually you can use the fixHTMLCode() method.

     
  • Nicola Asuni

    Nicola Asuni - 2014-09-05
    • status: open --> closed
     

Log in to post a comment.