Forum


Replies: 1   Views: 440
Dynamic images in the table
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 14-09-2023 - 12:07

Hello,

Which method are you using to create the table?

If you are using addTable you can use WordFragments. For example:

$imageA = new WordFragment($docx);
$options = array(
    'src' => 'imageA.png'
);
$imageA->addImage($options);

$imageB = new WordFragment($docx);
$options = array(
    'src' => 'imageB.png'
);
$imageB->addImage($options);

$valuesTable = array(
    array(
        'Title A',
        'Title B',
    ),
    array(
        $imageA,
        $imageB,
    )
);

$docx->addTable($valuesTable);

In the sample included in the package examples/Core/addTable/sample_2.php you can find how to generate a table with contents using WordFragments.

WordFragments can also be used with replaceTableVariable and many other phpdocx methods.

Regards.