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 Bouillou  · 15-03-2019 - 10:34

Hello,

How to display images side by side in a same table cell?

Here is my test which display the 2 images in the same table cell, but one above the other:

<?php

//path to  the CreateDocx class within your PHPDocX installation
require_once '../../../classes/CreateDocx.inc';

$docx = new CreateDocx();

//we create a few Word fragments to insert rich content in a table

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

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

$image = new WordFragment($docx);
$options = array(
    'src' => '../../img/image.png',
    'imageAlign' => 'left',
    'scaling' => 30,
    'textWrap' => 0
);

// Add 2 images in the WordFragemnt
$image->addImage($options);
$image->addImage($options);

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


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

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


$docx->createDocx('example_addTable_2');

Best regards,

Sébastien