News
Adding HTML to a template variable in PHPDocX
- Jun 06, 2011
Like add the contents of a docx document, you can add HTML in a variable of a template. You don't 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',
'David Hume
Character is the result of a system of stereotyped principles.',
'html');
$docx->createDocx('template_html_text');