News

Inserting a RFT document into your Word template

  • Jun 06, 2011

You may replace a single Word template variable by a full RTF document with the help of the addTemplateVariable method:




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 RTF document to the template
$docx->addTemplateVariable('NAME',
'../files/Text.rtf',
'rtf');

$docx->createDocx('template_rtf_text');