Forum


Replies: 1   Views: 4165
Replace template header variable using wordfragment not working
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 srinathasd  · 30-09-2014 - 09:17

i want to replace variables in header . but it not replaced. when i searching your document i see it is possible using replaceVariableByWordFragment method. http://www.zxcv.phpdocx.com/en/forum/default/topic/734 but it not working here is my code ** I try to also using target option ///////////////// require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('Doc.docx'); //create the Word fragment that is going to replace the variable $wf = new WordFragment($docx, 'document'); $text='try to add head'; $wf->addText($text); $docx->replaceVariableByWordFragment(array('TESTTT' => $wf), array('type' => 'inline','target' => 'footer')); $docx->createDocx('tessstb'); //////////////////////// //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('Doc.docx'); //create the Word fragment that is going to replace the variable $wf = new WordFragment($docx, 'document'); $text='try to add head'; $wf->addText($text); $docx->replaceVariableByWordFragment(array('TESTTT' => $wf), array('type' => 'block')); $docx->createDocx('tessst');

Posted by admin  · 01-10-2014 - 06:30

Hello, You have been answered by email. Regards.