Forum


Replies: 3   Views: 600
Images embedded in html are not reflecting in docx
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 jacquesduff  · 30-07-2021 - 15:05

Hi There,

I'm using "embedHTML" method of PHPDocx8 in php-version 7.3. Images included in the HTML are not showing in the created document. Earlier, it used to be worked properly.

The image permissions on the server are fine. Even, I tried it with different extensions png, jpg.

Here is the code:

$docx = new CreateDocxFromTemplate(getcwd() . $clinicLetterheadPath);
$letter_data = '<span id="letter_date">31/07/2021</span><br />
Test Document 
<p><img src="https://domain-name.com/editor/uploads/test.jpg" /></p>
<h6>Signatures</h6>';
$letter_data = '<style>p {margin: 0px; padding: 0px; font-weight: normal;}</style>' . $letter_data;
$letter_options = array(
  'useHTMLExtended' => true,
  'downloadImages' => true,
  'parseDivs' => 'paragraph',
);
$docx->embedHTML($letter_data, $letter_options);
$path = getcwd() . "/pdftemp/";
$filepath = $path . $filename;
$docx->createDocx($filepath);

Can someone please suggest if there is in-compatibility with the PHP upgraded version? How we can debug it? There are no logs in the package directory!

Thanks

Posted by admin  · 30-07-2021 - 15:41

Hello,

phpdocx is compatible with PHP 7.3 since the release of phpdocx 8.5 (https://www.phpdocx.com/news/post/phpdocx-v8-5-release-notes/217). The current stable version, phpdocx 11, is compatible with all versions from PHP 5.2.11 to PHP 8. We are not sure if your problem comes from using PHP 7.3 with an old version of phpdocx, but if the same code worked with a previous version of PHP, then the problem must come from using an old version of phpdocx with a not supported version of PHP.

We recommend upgrading your license to use phpdocx with PHP 7.3 and newer PHP versions, and also test your script using the PHP CLI mode to check if you get some errors. You can test phpdocx 11 with embedHTML using the trial package (https://www.phpdocx.com/download_trial) before upgrading your license.

If you are downloading images from HTTPs we also recommend checking the documentation available on https://www.phpdocx.com/documentation/cookbook/insert-images-html (From HTTPS section).

Also, note that HTML Extended is only available in Premium licenses since phpdocx 9.0. Using a previous version and a Basic license as your username has tied, you can't set useHTMLExtended to true (well, you can, but it won't do anything because this option is only available in Premium licenses.).

If needed, you can send a sample script with a valid image URL to contact[at]phpdocx.com and the dev team will check it.

About logs, you can find PHP warnings and errors in your server logs, and also use any PSR-3 logger (https://www.phpdocx.com/documentation/introduction/tutorial Appendix: debugging options section).

Regards.

Posted by jacquesduff  · 02-10-2021 - 11:32

Thanks for the response!

I’ve tested the functionality with the Trial package phpdocx11 and still images are not loading. Seems like, PHP version is not an issue.

I tried to enable a relative path as well, no luck!

Can you please suggest that what to do next? Can I send a sample script to your support email address?

Posted by admin  · 02-10-2021 - 18:56

Hello,

You can send the simplest script that illustrates your issue to contact[at]phpdocx.com, for example a script that adds an image from your server, and we'll check it. We need to run it, so the script must use phpdocx standalone without using external resources such as databases, web services, frameworks or CMS.

Embedding images using HTML methods and all image methods are fully tested and working with all PHP versions from PHP 5.2.11 to PHP 8. We recommend you to check the samples included in the package. If the image is not being added is because it can't be readed correctly; after you have sent the sample script will know where the issue comes from.

Regards.