Forum


Replies: 2   Views: 1277
Add image using template tags in bulk processing
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 ascendware  · 21-09-2020 - 16:02

Hi,

I would like to insert an image in the document using the WordFragment > addImage method, but it is giving me an error: Fatal error: Call to a member function addFile() on null.

Another reason why I need to use the WordFragment > addImage is because I need to insert images inside the table while running in the bulk document processing.

How can I achieve this?

 

Thank you very much.

Posted by admin  · 21-09-2020 - 16:40

Hello,

Replacing placeholders by WordFragments with BulkProcessing methods work with WordFragments that doesn't require injecting the DOCX target.

If you check the API page and the included samples, you can check that all WordFragments added with BulkProcessing use the following structure:

$wordFragment = new WordFragment();

that works perfectly with contents such as texts, links and others that doesn't require adding external files.

But adding an image as WordFragment requires setting the $docx target to add the image:

$wordFragment = new WordFragment($docx);

We have moved the request to the dev team to add support in BulkProcessing too. Using the current stable version of phpdocx, we recommend you to use replaceVariableByWordFragment to accomplish this task with this kind of WordFragments instead of BulkProcessing.

Regards.

Posted by ascendware  · 22-09-2020 - 08:01

Noted on this. Thank you very much.