Images in PDF displays as a red cross (https / mpdf)

First  please make sure, that you are not on a localhost AND do not have any .htaccess / .passwd on your sever. Because our plugin uses HTTP to get the images for the PDF creation and if your server blocks the images from public it won’t work.

Problem not solves? Read further:

Please make sure you have installed / configured the following in your Server PHP Extensions:

  1. CURL Enabled (php_curl.dll enabled)
  2. PHP.ini (allow_url_fopen = On)
  3. GD Library installed

To debug image loading go to plugin settings > advanced settings. There enable the MPDF Debug mode:

MPDF debug mode
MPDF debug mode

Look what the image errors show. Maybe you find the issue yourself.

If images still do not display you can solve the issue by the following ways:

Quick and Dirty:

Add the following to the mpdf.php file on line 12954 -> function: file_get_contents_by_curl()

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Source: https://stackoverflow.com/questions/5657382/curl-php-restful-service-always-returning-false

Better:

The better solution is to manually add only the certificate(s) or CA(s) you want to accept

;;;;;;;;;;;;;;;;;;;;
; php.ini Options  ;
;;;;;;;;;;;;;;;;;;;;

curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"

Source: https://stackoverflow.com/questions/24611640/curl-60-ssl-certificate-unable-to-get-local-issuer-certificate

On Nginx?

Some nginx server disallow some agents in the CURL header. Therefore you will need to change the header. Go to plugin-folder/includes/mpdf/mpdf.php > Line: 12965.

Then change the CURLOPT_USERAGENT value to ‘User-Agent: curl/7.39.0’

Example:

curl_setopt($ch, CURLOPT_USERAGENT, 'User-Agent: curl/7.39.0');

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.