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.
I'd like to include breaks in my word file, so I use following code:
$docx = new \CreateDocxFromTemplate("replacePlaceholderImages1.docx");
$docx->replaceVariableByText(array("FOO" => "some & text \n foo"), array("target" => "header", "parseLineBreaks" => true));
$docx->createDocx('/tmp/example_replacePlaceholderImages_1');
But I get an exception:
ContextErrorException: Warning: DOMDocument::createElementNS(): unterminated entity reference text in [...]/phpdocx/classes/CreateDocxFromTemplate.inc line 1297
Exception seems due to the presence of '&' symbol
Hello,
Yes, you need to escape that character and others like '&', '>'...
Regards.
Ok thanks,
As I've no problem with & symbol when I use the default behavior (parseLineBreaks == false), then I need to protect some symbols only when parseLineBreaks is set to true right ?
And then 2 questions:
* which php function should I use to protect those symbols when parseLineBreaks is activated ? htmlspecialchars, another function ?
* why not performing automatically this character convertion in the lib ? as the replaceVariableByText only accepts text as input, no Word fragment or so on, no?
Hello,
Please send the questions to contact@phpdocx.com to get the support.
Regards.
I have the same issue, was this ever resolved?
Regards, Andy
Hello,
That issue was fixed for all phpdocx versions.
Regards.