Forum


Replies: 2   Views: 3035
Replacevariablebyhtml() introducing leading space and/or newlines.
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 jcorrao  · 19-12-2017 - 18:20

Utilizing PHPdocX 6.5, with a minimally reproducible case being a bare document with a single template variable "bio-summaries"

$docx = new Phpdocx\Create\CreateDocxFromTemplate('./bioSummary.docx');

$stylesArray = array('<p>' => 'Normal', '<h1>' => 'Heading1', '<h2>' => 'Heading2');

$docx->replaceVariableByHTML('bio-summaries', 'block', "<strong>HELLO</strong> <em>world</em>! My name is <ul><li>First</li><li>Middle</li><li>Last</li></ul>", array(
    'strictWordStyles' => FALSE,
    'downloadImages' => TRUE,
    'wordStyles' => $stylesArray,
  ));

$docx->createDocx('result.docx');

Regardless of any of the three options being provided or not, TRUE or FALSE as well, every line has a leading space, and every bullet point has a leading space as well.

I have taken care to test it with a wrapper "<div>" and stripping out "/r" "/n" "/r/n", etc from the input as well, but to no avail.

If anyone could please assist in discerning the cause of the issue, it would be much appreciated.

 

Edit/Update:
It seems after further diving, that it's a problem with HTML2WordML's render functionality that renders each WordML token with a newline despite the input having no newline.