Forum


Replies: 6   Views: 2245
Addimage null error
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  · 05-03-2020 - 18:25

Hello,

If the script returns:

Call to a member function addImage() on null

then $rooms_image in $rooms_image->addImage($image_options); is null, not a CreateDocx/CreateDocxFromTemplate instance. And also, as we can check in the output sent, the error appears in the script you are running:

Call to a member function addImage() on null

File 
BrochureHelpers.php

If an exception or error is returned by phpdocx, then a phpdocx class appears, not an external script (BrochureHelpers.php).

Maybe your code has a conditional that generates a correct CreateDocx object based on the image (or other condition) and in some cases, the object is not being generated correctly?

phpdocx doesn't throw a null error if an image can't be added, it returns an image error exception.

We recommend you to run the included samples and test addImage standalone with the same images: https://www.phpdocx.com/api-documentation/word-content/insert-image-Word-document-with-PHP, so you can find the source of the problem.

Regards.