Forum


Replies: 1   Views: 3210
Replacevariablebyhtml and special chars
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 michealorion  · 05-12-2016 - 10:08

Hello

I have this HTML string converted by php function htmlentities

string(92) "<p>This special chars à è ì ù ò<br></p>"

When i use the function replaceVariableByHtml in output document there is the strings with all html tags like when i use replaceVariablebyText

this is my code:

require_once '../../core/com/phpdocx/classes/CreateDocx.inc';
$docx = new CreateDocxFromTemplate('template/template.docx');
$variabiliTemplate=$docx->getTemplateVariables();
//get my template varables
$sostituzioniDaModello = $memo->audit->getElementiModelloProgetto($proj->idmodello);
foreach ($sostituzioniDaModello as $index => $field){
   if(in_array($field,$variabiliTemplate['document'])){
        //get value of element and parse htlm
        $html = htmlentities($proj->getElemento($index)); 
        $docx->replaceVariableByHtml($field,'block',$html); 
    }
}
$docx->createDocx('template/documento.docx');


Can i help me?

Thanks for support

Posted by admin  · 05-12-2016 - 12:17

Hello,

We recommend you to read these pages:

http://www.phpdocx.com/documentation/cookbook/convert-html-to-word

http://www.phpdocx.com/documentation/cookbook/working-with-special-characters

You don't need to escape accents. If you use htmlentities to transform HTML tags, then they won't be transformed to Word as the tags are not readed.

Besides all included examples and documentation pages, after you have purchased a license we can generate a sample to show you how to do it.

Regards.