Forum


Replies: 2   Views: 2007
Table cell starts with empty line
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by kobbe  · 04-12-2019 - 12:55

I have a simple table where the <td> start with empty line or <br>.

The result is that the second line get a space in begining.

I have checked the HTML and it is only like this <td><br>Second line</td>

See: https://ibb.co/F0LMGmt

I am using the embedHTML function and phpdocx v9.0.

How do I get rid of the extra space?

Posted by admin  · 04-12-2019 - 13:09

Hello,

We recommend you to wrap that content using a HTML tag (such as a paragraph or a span tag), for example:

$docx->embedHTML('
    <table>
        <tr>
            <td><br><p>First cell</p></td>
            <td>Second cell</td>
            <td>Third cell</td>
        </tr>
        <tr>
            <td>2.1 cell</td>
            <td>2.2 cell</td>
            <td>2.3 cell</td>
        </tr>
    </table>
');

Or use the removeLineBreaks option:

$docx->embedHTML('
    <table>
        <tr>
            <td><br>First cell</td>
            <td>Second cell</td>
            <td>Third cell</td>
        </tr>
        <tr>
            <td>2.1 cell</td>
            <td>2.2 cell</td>
            <td>2.3 cell</td>
        </tr>
    </table>
', array('removeLineBreaks' => true));

to clean extra line breaks that may be generated by PHP Tidy.

Regards.

Posted by kobbe  · 04-12-2019 - 15:44

Thank you very much, worked perfect! Did not have to use removeLineBreaks.