Replies: 1   Views: 3739
Cannot show image in a table in header or footer
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 entudi  · 20-07-2016 - 04:12

Hi guys,

I'm using PHPDOCX version 4.0. I'm trying to show header with the text on the left and an image on the right. My idea is that I add a table with two column, set border: none and add the text to the left cell, and the image on the right cell. You can see my code below:

$docx = new CreateDocx();
//we create a few Word fragments to insert rich content in a table
$dateFragment = new \WordFragment($docx);
$imageFragment = new \WordFragment($docx);
$headerFragment = new \WordFragment($docx, 'defaultHeader');
    'text' => date('d/m/Y'),
    'fontSize' => 11,
    'font' => 'Calibri'
$imageOptions = array(
    'src' => 'full_screen_image.jpg', 
    'dpi' => 300,  
    'width' => 300,
    'height' => 200,
    'imageAlign' => 'right'
$valuesTable = array(
$paramsTable = array(
    'tableAlign' => 'center',
    'columnWidths' => array(4500, 4500),
    'border' => 'none'
$headerFragment->addTable($valuesTable, $paramsTable);
$docx->addHeader(array('default' => $headerFragment));

But in my result docx file, the image cannot be shown. You can check my screenshot in the following link:

Please help me to figure out the reason why this issue happen, and how we can resolve it.

Thank you.