Forum


Replies: 1   Views: 480
How do i add images to the end of a 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 rabol  · 08-05-2023 - 13:45

Hi

I have a dynamic list of images that I would like to add at the end of a document.

Let's say I have 3 images, then for the for the first I would like to go to the end of the document, add a new line and then add the image, the same for th 2nd and 3rd image.

How can I do that ?

 

Thanks

Posted by admin  · 08-05-2023 - 15:23

Hello,

By default, all contents are added at the end of the document.

For example, generating a new DOCX with a text and an image:

$docx = new CreateDocx();

$docx->addText('My paragraph');

$docx->addImage(array('src' => 'image.png'));

And the same using an existing DOCX:

$docx = new CreateDocxFromTemplate('document.docx');

$docx->addText('My paragraph');

$docx->addImage(array('src' => 'image.png'));

When you use an existing DOCX with CreateDocxFromTemplate all contents are kept. New contents are added at the end of the document using methods such as addText or addImage.

Regards.