Like add the contents of a docx document, you can add HTML in a variable of a template. You don need to call a document, ut ad this HTML manually or using other import functions.
Here is the code:
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$docx->addTemplate('../files/TemplateText.docx');
$docx->addTemplateVariable('WEIGHT1', '10');
$docx->addTemplateVariable('WEIGHT2', '20');
$docx->addTemplateVariable('WEIGHT3', '25');
$docx->addTemplateVariable('PRICE1', '5');
$docx->addTemplateVariable('PRICE2', '30');
$docx->addTemplateVariable('PRICE3', '7');
$docx->addTemplateVariable('TOTALWEIGHT', '55');
$docx->addTemplateVariable('TOTALPRICE', '42');
// Adding the HTML
$docx->addTemplateVariable('NAME',
'<strong>David Hume</strong><br />
<em>Character is the result of a system of stereotyped principles.</em>',
'html');
$docx->createDocx('template_html_text');
Iff you have additional content in a docx document, you can append it using a variable that call this document and place the text inside where you define the variable.

This is the code:
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$docx->addTemplate('../files/TemplateText.docx');
$docx->addTemplateVariable('WEIGHT1', '10');
$docx->addTemplateVariable('WEIGHT2', '20');
$docx->addTemplateVariable('WEIGHT3', '25');
$docx->addTemplateVariable('PRICE1', '5');
$docx->addTemplateVariable('PRICE2', '30');
$docx->addTemplateVariable('PRICE3', '7');
$docx->addTemplateVariable('TOTALWEIGHT', '55');
$docx->addTemplateVariable('TOTALPRICE', '42');
// Add the content of the document when $NAME$ variable is called.
$docx->addTemplateVariable('NAME', '../files/Text.docx', 'docx');
$docx->createDocx('template_docx_text');
Adding an image to a template is easy: as in other templates, you need to asign a variable to the docx document like $IMAGE$ or $VARIATIONS_OF_IMAGE$ or other names and call it from the code:
require_once '../../classes/CreateDocx.inc';
$objDocx = new CreateDocx();
// Call the template
$objDocx->addTemplate('../files/TemplateImage.docx');
// Call the image
$objDocx->addTemplateImage('IMAGE', '../files/img/logo_phpdocx.gif');
$objDocx->createDocx('template_image');
Read the rest of this entry »
In the new version PHPdocx 2.3 we add checkboxes support for templates.
Write in a docx document
$CHECK_1$ Field One
$CHECK_2$ Field Two
$CHECK_3$ Field Three
Add some checkboxes is really easy, use this code for a template:
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
// Calling the template
$docx->addTemplate('../files/TemplateCheckbox.docx');
$docx->addTemplateCheckBox('1', 'First');
$docx->addTemplateCheckBox('2', 'Second');
$docx->addTemplateCheckBox('3', 'Third');
$docx->createDocx('template_checkbox');
Read the rest of this entry »
Need two, three or more columns for your text? You can define any number of columns you will need using this code:
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ' .
'enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut' .
'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit ' .
'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' .
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui ' .
'officia deserunt mollit anim id est laborum.';
$docx->addText($text);
$paramsPage = array(
'titlePage' => 1,
// Number of columns
'columns' => 3,
// Orientation of the paper. Could be 'Landscape'
'orient' => 'normal',
'top' => 4000,
'bottom' => 4000,
'right' => 4000,
'left' => 4000
);
$docx->createDocx('example_textcolumns', $paramsPage);