Forum


Replies: 8   Views: 4844
Using wordstyles to format replacevariablebyhtml output possible?
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 nicks  · 28-12-2015 - 21:37

Hi,

Having issues with replaceVariableByHTML to replace a tag in a Word file, and trying to format this replaced HTML code from CKEditor to a customised Word Style (font2) that is already in the Word Template. It works fine with addText, though just doesn't work with replaceVariableByHTML.

Any idea what I am doing wrong?

Test code below:

<?php
require_once '../phpdocx_corporate-new/classes/CreateDocx.inc';
$docx = new CreateDocxFromTemplate('template4.docx');
$styles = array('pStyle' => 'font2');
$docx->replaceVariableByHTML('PIC', 'block', '<p>This lack of <span style="color:#FF0000">detail</span> could mean a system does not <span style="background-color:#00FFFF">function correctly.</span></p>
', array('isFile' => false,'wordStyles' => $styles));
$docx->addText('This is some sample paragraph test', array('pStyle' => 'font2'));
$docx->createDocx('test4');
header("Content-type:application/vnd.openxmlformats-officedocument.wordprocessingml.document");
header("Content-disposition:attachment;filename=test4");
readfile('test4.docx');
?>