Forum


Replies: 3   Views: 707
Image url also getting printed in .docx file
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  · 03-11-2022 - 18:32

Hello,

The addImage method adds a new image, it doesn't replace a text placeholder or an existing image in a DOCX template.

You need to use replacePlaceholderImage to replace an existing image that includes a placeholder added as alternative text. Or replaceVariableByWordFragment to replace a text placeholder by a new image.

On the following practical guide: Pictures and images , and the API documentation pages of the methods you can find further information and samples. You can also find more samples in the package.

Also note the following:

  • Adding a stream with addImage may require enabling the streamMode available in the method. As detailed on the API documention pages:

src

The path to the image or base64 string or stream to be inserted into the Word document. If a stream is added, use with the streamMode option.

Regards.