<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocx(); $docx->addText('This example illustrates how to add a mergefield to a Word document.'); $mergeParameters = array('format' => 'Upper', 'textBefore' => 'A mergefield example: ', 'textAfter' => ' and some text afterwards.'); $options = array('color' => 'B70000'); $docx->addMergeField('MyMergeField example', $mergeParameters, $options); //remove the shading from the mergeField data $docx->docxSettings(array('doNotShadeFormData' => 0)); $docx->createDocx('example_addMergeField_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocx(); $settings = array('view' => 'outline', 'zoom' => 70); $text = 'In this case we set the view mode as "outline" and ' . 'the default zoom on openning to 70%.'; $docx->addText($text); $docx->docxSettings($settings); $docx->createDocx('example_docxSettings_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocx(); //first we add certain properties to our Word document $properties = array('title' => 'The title of the document.', 'creator' => 'The autor of the document.', 'description' => 'A description of the document.'); $docx->addProperties($properties); $docx->addText('We add a few simple fields that render the above properties:'); $options = array('pStyle' => 'Heading1PHPDOCX'); $docx->addSimpleField('TITLE', '', '', $options); $docx->addSimpleField('AUTHOR'); $docx->addSimpleField('NUMPAGES'); $docx->addSimpleField('COMMENTS'); //we prompt the user to updat the fields on openning $docx->docxSettings(array('updateFields' => 'true')); $docx->createDocx('example_addSimpleField_1');