Forum


Replies: 2   Views: 3441
Image not appearing in the word document.
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 fueldigital-dev  · 13-03-2013 - 07:20


$docx->addTemplateVariable($field2,$imagepath,'html');


$FIELD2_IMAGES$

When i tried to insert an image into the word document, the images where not appearing.

I could see a blank page for that image.


I use custom build function to loop through the glob to look for all images and split to the word.

function images($docx,$field1,$field2,$inspector_name,$inspector_session)
{
$inspection_type = "BuildingReport-";
$folder_final = 'uploads'.'/'.$inspector_name.'/'.$inspector_session.'/'.$inspection_type;

// Scanning the thumbnail folder for JPG images:
$g = glob($folder_final.'/original/*.jpg');

if(!$g){
$g = array();
}
$names = array();
$section = array();
$modified = array();

// We loop though the file names returned by glob,
// and we populate a second file with modifed timestamps.
$image_section = $field1;
$j = 1;
$imageString = '';

for($i=0,$z=count($g);$i<$z;$i++){
if(strstr($g[$i],$image_section)!=FALSE)
{
$imageString .= "<img width=\"300\" height=\"225\" src=\"http://www.test.com/form/".$g[$i]."\"><br><br>";
$imageStringArr[] = "<img src=\"".$g[$i]."\">";
}
}

if(sizeof($imageStringArr)!=0)
{
$docx->addTemplateVariable($field2,$imageString,'html');
}
else
{
$docx->addTemplateVariable($field2, '');
}
}


Can you please tell me what i am doing wrong. Is there any alternative functions that i could use ?