Hello,
Yes, you are right, we didn't test that specific case and it returns an error. The problem comes from the textbox; complex replacements such as replacing a placeholder by a chart in a textbox may require using DOCXPath that is more flexible.
You can use two approaches to fix your issue.
1. Use DOCXPath (it's the easiest solution): instead of the replaceVariableByWordFragment method, you need to use the replaceWordContent one:
<?php
require_once 'classes/MultiMerge.inc';
$docx = new CreateDocxFromTemplate('FBTemplate_Cat.docx');
$chart = new WordFragment($docx, "document");
$data = array(
'legend' => array('Legend 1', 'Legend 2', 'Legend 3'),
'data' => array(
array(
'name' => 'data 1',
'values' => array(10, 20, 5),
),
array(
'name' => 'data 2',
'values' => array(20, 60, 3),
),
array(
'name' => 'data 3',
'values' => array(50, 33, 7),
),
),
);
$paramsChart = array(
'data' => $data,
'type' => 'barChart',
'color' => 5,
'sizeX' => 15,
'sizeY' => 10,
'chartAlign' => 'center',
'legendPos' => 'none',
'legendOverlay' => '0',
'border' => '1',
'hgrid' => '1',
'vgrid' => '0',
'showTable' => '1'
);
$chart->addChart($paramsChart);
$referenceNode = array(
'type' => 'paragraph',
'contains' => 'Ranking_1',
);
$docx->replaceWordContent($chart, $referenceNode);
$docx->createDocx('output_3');
$merge = new MultiMerge();
$merge->mergeDocx('Test_Front_Page.docx', array('output_3.docx'), 'output_2.docx', array());
2. Use the replaceVariableByWordFragment method but first, you merge the DOCX documents and then you replace the placeholder.
Using any of these approaches will generate the correct output.
Regards.
Regards.