Forum


Replies: 2   Views: 2256
How to display 2 images side by side in a same table cell?
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  · 15-03-2019 - 15:57

Hello,

You need to generate a text WordFragment and add the images:

$link = new WordFragment($docx);
$options = array(
    'url' => 'http://www.google.es'
);

$link->addLink('Link to Google', $options);

$image = new WordFragment($docx);
$options = array(
    'src' => 'image.png',
    'width' => 50,
    'height' => 50,
);

$image->addImage($options);

$text = array();
$text[] = $image;
$text[] = $image;

$textFragment = new WordFragment($docx);
$textFragment->addText($text);

$valuesTable = array(
    array(
        'Title A',
        'Title B',
        'Title C',
    ),
    array(
        'Line A',
        $link,
        $textFragment,
    )
);


$paramsTable = array(
    'tableStyle' => 'LightListAccent1PHPDOCX',
    'tableAlign' => 'center',
    'columnWidths' => array(1000, 2500, 3000),
    );

$docx->addTable($valuesTable, $paramsTable);

to avoid adding a paragraph for each image. In the file examples/Core/addText/sample_3.php you can see a sample using run of text contents, out of a table but it works in the same way.

Regards.