Forum


Replies: 3   Views: 3400
Strange chars in phpdocx out
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 kpholland  · 11-04-2016 - 14:51

I have a Mysql database with a TEXT type field. When i use this field in our Word PHPdocx template i'am getting this as result (see text below). I have tryed htmlspecialchars_decode/html_entity_decode on the field before putting it in the PHPdocx array ($wf->addTable($Array_Table_Value, $paramsTable);
)... But the result is still the same <p> and \r and \n still visible in mine PHPdocx Output file :(

 

 

<p>Inhoud gesprek</p>\r\n\r\n<p>Dit is een test bericht</p>\r\n\r\n<p>En nog een regel</p>\r\n\r\n<p>En nog een regel</p>\r\n

 

Posted by admin  · 12-04-2016 - 06:26

Hello,

If your database includes \r, \n... and you won't to add them into the document, we recommend you to remove them. For example using str_replace to clear '\r', '\n' and "\r", "\n"... to remove literal strings and carriage returns.

Regards.

Posted by kpholland  · 12-04-2016 - 06:58

If i use this code (see below). The <p> are replaced bij \r (not wat i want) I want to replace the <p> with a  'normal' breakline(enter)

$row_TEMP['MEMO'] = str_replace("<p>", '\r', html_entity_decode($row_TEMP['MEMO']) );

------------------------

The only thing that i want to do is: I have a array (with sql/text(blob field) that i put in a phpdocx addTable function.

$wf = new WordFragment($docx, 'document');
$wf->addTable($Array_Table_Value, $paramsTable);
$docx->replaceVariableByWordFragment(array('Array_Table_Value' => $wf), array('type' => 'block'));
 

 

Posted by admin  · 12-04-2016 - 08:43

Hello,

To do a line break you need to use the addBreak method (standalone or as a WordFragment) or the parseLineBreaks option when using replace* methods.

Regards.