Hello,
That blank spaces may be due to the vertical-space option from Tidy (https://stackoverflow.com/questions/2491657/how-do-i-get-html-tidy-to-not-put-newline-before-closing-tags), but some versions of Tidy may cause this issue.
The next relase of phpdocx will include a new option to clean these breaks that come from some Tidy versions/configurations (line breaks after closing tags). We recommend you to edit the classes/CreateDocx.php file, and change the following lines (in the embedHTML method):
if ($class == 'WordFragment') {
if (isset($options['removeLineBreaks']) && $options['removeLineBreaks'] == true) {
$this->wordML .= (string) str_replace(array("\n", "\r\n"), '', $sFinalDocX[0]);
} else {
$this->wordML .= (string) $sFinalDocX[0];
}
} else {
if (isset($options['removeLineBreaks']) && $options['removeLineBreaks'] == true) {
$this->_wordDocumentC .= (string) str_replace(array("\n", "\r\n"), '', $sFinalDocX[0]);
} else {
$this->_wordDocumentC .= (string) $sFinalDocX[0];
}
}
with:
if ($class == 'WordFragment') {
if (isset($options['removeLineBreaks']) && $options['removeLineBreaks'] == true) {
$this->wordML .= (string) str_replace(array(">\n", ">\r\n"), '>', $sFinalDocX[0]);
} else {
$this->wordML .= (string) $sFinalDocX[0];
}
} else {
if (isset($options['removeLineBreaks']) && $options['removeLineBreaks'] == true) {
$this->_wordDocumentC .= (string) str_replace(array(">\n", ">\r\n"), '>', $sFinalDocX[0]);
} else {
$this->_wordDocumentC .= (string) $sFinalDocX[0];
}
}
And set removeLineBreaks as true. This change removes the line breaks after start tags and should fix your issue. If you are not using the classic package but the namespaces one, please keep the namespaces in the same code.
Regards.