Forum


Replies: 9   Views: 4367
Cannot find image
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 jari.heinonen  · 29-12-2014 - 08:24

Hi, Is it (still) possbile to retrieve the image from a DB and place it into the docx document without creating first a file into the file system? We are currently trying to upgrade to phptodocx 4.1 but images causes us quite a headache. In 3.7 we were able to retrieve images (photos) directly from the db and place them on the docx. But with 4.1. our code below does not work anymore. Please, could you please give us a hint what to do? // $photos array is retrieved from the database foreach ($photos as $photo) { $imageElement = addImage($photo, true, $this->imageSize); $col1['value'] = createWordMLFragment(array($imageElement)); $col2['value'] = ... $imageTable[] = array($col1, $col2); // The MS word table will have images per table row addTable($imageTable, $imageTableProperties, $imageRowProperties); .... In 4.1 documentation there are plenty of examples for handling image file from the file system. When testing with image files all other parts of our code works OK. For us it would be much more convenient to retrieve images directly from database. $photo = 'photo1.jpg' $paramsImg = array( 'src' => $photo, ...... (other parameters)); $imageFragment = new WordFragment($this->document); $imageFragment->addImage($paramsImg); ..