I am using a word document generator for PHP for the reports module of the web-app i am developing. I choose PHPWord because the free version of PHPDocX has very limited functionality plus it has a footer that it is only a free version. I have a template given by the client. What I want is I want to load the template and add dynamic elements to it like additional text or tables. My code is here:
<?php
require_once '../PHPWord.php';
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate('Template.docx');
$document->setValue('Value1', 'Great');
$section = $PHPWord->createSection();
$section->addText('Hello World!');
$section->addTextBreak(2);
$document->setValue('Value2', $section);
$document->save('test.docx');
?>
I tried to create a new section and tried to assign it to one variable in the template(Value2) but this error appeared:
[28-Jan-2013 10:36:37 UTC] PHP Warning: utf8_encode() expects parameter 1 to be string, object given in /Users/admin/localhost/PHPWord_0.6.2_Beta/PHPWord/Template.php on line 99