Replies: 1   Views: 3776
Unwanted line break when adding html to table cell
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 lincus  · 14-03-2012 - 16:40


I have a problem with adding very simple HTML to a table cell in a template, via the addTemplateVariable(..., ..., 'html') method. Indeed, a line break is automatically generated after my HTML code in the cell.
My table cell is part of a table in a template and only comprise a variable, e.g. $MYVARIABLE$. Nothing else in the cell.
My code is as follows:
$docx->addTemplateVariable('MYVARIABLE', '<a style="color: #c75f3e; font: bold 10px Verdana, Arial, Helvetica, sans-serif;" href="">Follow this link</a>', 'html');

The result is good, except that there is a line break after my link in the final document. This poses problems because my cell is supposed to be at a certain precise height, which is automatically increased by the unwanted line break.
Unfortunately, I need to use this method and can't use the addLink method instead.
Could someone help, please? Thanks!

I don't know if the problem might be there, but the document.xml file for this template reads as follows (for the part dedicated to this cell):
<w:tcW w:w="2268" w:type="dxa" />
<w:vAlign w:val="center" />
<w:p w:rsidR="00A030FF" w:rsidRPr="00A030FF" w:rsidRDefault="00CF623C" w:rsidP="00566107">
<w:jc w:val="center" />
<w:rFonts w:ascii="Verdana" w:hAnsi="Verdana" />
<w:b />
<w:sz w:val="14" />
<w:rFonts w:ascii="Verdana" w:hAnsi="Verdana" />
<w:b />
<w:sz w:val="14" />