Forum


Replies: 1   Views: 933
Issues using replacevariablebyexternalfile with html containing images
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 mcaldas  · 16-11-2021 - 16:50

Good evening, I'm having some issues with the replaceVariableByExternalFile function everytime I embed an HTML file into Word. This HTML has multiple images, and for some reason the resulting docx is not including the 3rd image. I discarded that the image is corrupted by switching positions with other images. In this case no matter what image is in the 3erd position, it disappears.

When I change the extension to zip and check the inner files, I find the html with the image, but it is not shown on Word.

My most recent test was taking the same html that is used by the function and embedding it directly to Word and it works so I think the function has some issues.

 

I hope you can help me finding some way to make this work.

Posted by admin  · 16-11-2021 - 18:58

Hello,

The replaceVariableByExternalFile method uses altChunk tags. As explained on the API documentation page, this tag is supported only by MS Word 2007 or newer in Windows. Other DOCX readers don't support this tag, that has some limitations and as MS Word handles its contents, it can't be customized to change how it is displayed.

The recommended method to replace a placeholder by HTML is replaceVariableByHTML, that generates documents supported by all DOCX readers and can be customized using the available options.

We recommend you to use replaceVariableByHTML to get the best output and compatibility, but if you send to contact[at]phpdocx.con the HTML you are embedding using replaceVariableByExternalFile we'll do some tests with this method (replaceVariableByExternalFile).

Regards.