Forum


Replies: 6   Views: 5102
Fatal error: call to a member function addfromstring()
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 pbg@pbgpersonnel.ru  · 17-04-2015 - 15:14

Hello, I try put chart in variable. ..... $chart = new WordFragment(); $data = array( 'Legend 1' => array(20), 'Legend 2' => array(30), 'Legend 3' => array(40) ); $paramsChart = array( 'data' => $data, 'type' => 'pie3DChart' ); $chart->addChart($paramsChart); $docx->replaceVariableByWordML(array('QUESTION_6_CHART' => $chart)); .... Browser shows this is: Fatal error: Call to a member function addFromString() on a non-object in ...../tools/4.6/classes/CreateDocx.inc on line 1188 -------- php check.php OK PHP version is 5.3.18 OK Zip support is enabled. OK DOM support is enabled. OK XML support is enabled. OK Tidy support is enabled. If you have any issue or problem please send us the following info: PHP_VERSION: 5.3.18 PHP_OS: Linux PHP_UNAME: Linux sdi5.example.ru 2.6.33.20-bitrix10 #6 SMP Thu Nov 24 17:29:20 MSK 2011 x86_64 SERVER_NAME: SERVER_SOFTWARE: SERVER_ADDR: SERVER_PROTOCOL: HTTP_HOST: HTTP_X_FORWARDED_FOR: PHP_SELF: check.php ZipArchive: 1 DomDocument: 1 SimpleXMLElement: 1 Tidy: 1

Posted by admin  · 18-04-2015 - 07:29

Hello, You need to the replaceVariableByWordFragment replaceVariableByWordML not replaceVariableByWordML. Please read these pages fo more information: http://www.phpdocx.com/api-documentation/templates/replace-variable-word-fragment-Word-document http://www.phpdocx.com/api-documentation/templates/replace-variable-wordml-Word-document Regards.

Posted by pbg@pbgpersonnel.ru  · 20-04-2015 - 07:15

I changed to replaceVariableByWordFragment. The same error. From CLI too.

Posted by admin  · 20-04-2015 - 08:15

Hello, Please run the included examples in the Templates/replaceVariableByWordFragment folder and check if the output is fine. And please send to contact[at]phpdocx.com the most simple script that illustrates the problem. Regards.

Posted by pbg@pbgpersonnel.ru  · 20-04-2015 - 08:59

Examples is working. But this script is not. ---------------------------------- require_once('../../../classes/CreateDocx.inc'); $docx = new CreateDocxFromTemplate('../../files/TemplateWordFragment_3.docx'); $chart = new WordFragment(); $data = array( 'Legend 1' => array(20), 'Legend 2' => array(30), 'Legend 3' => array(40) ); $paramsChart = array( 'data' => $data, 'type' => 'pie3DChart' ); $chart->addChart($paramsChart); $docx->replaceVariableByWordFragment(array('WORDFRAGMENT_BODY' => $chart), array('type' => 'block')); $docx->createDocx('example_replaceVariableByExternalFile_chart');

Posted by admin  · 20-04-2015 - 11:22

Hello, You can't invoke this line: $chart = new WordFragment(); without the main $docx. If you check the included examples in detail, you'll see this line: $wf = new WordFragment($docx, 'document'); You need to set the main $docx where to use the WordFragment object. Regards.

Posted by pbg@pbgpersonnel.ru  · 20-04-2015 - 11:29

It's working. 8-) Thank you