mPDF 5.7.1 - image displays as a broken [x]

后端 未结 11 1188
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 05:59

I have a small issue with mPDF (version 5.7.1).

This code should generate PDF with image file:

 $mpdf = new mPDF();
 $html = \'

        
相关标签:
11条回答
  • 2020-12-29 06:26

    It's enough The solve is :

    $mpdf->curlAllowUnsafeSslRequests = true;
    

    It's all

    0 讨论(0)
  • 2020-12-29 06:31

    You can try this:

    $mpdf->imageVars['myvariable'] = file_get_contents('alpha.png');
    

    or

    $html = '<img src="var:myvariable"/>';
    $mpdf->WriteHTML($html);
    

    after there, you should do:

    $mpdf->Image('var:myvariable', 0, 0);
    

    read more about this in documentation: mPDF Load Image

    0 讨论(0)
  • 2020-12-29 06:32

    I am using Code Ignitor and mpdf. After installing php-gd5 library, I had to re-install the php with configure command --with-gd to resolve the issue

    0 讨论(0)
  • 2020-12-29 06:33

    I have encountered the same problem after migrating the script.

    The problem was, that the tmp directory inside the mpdf folder was not writable. I hope it helps someone.

    0 讨论(0)
  • 2020-12-29 06:35

    In my project i fix problem and solution is:

    Set src absolute path on the server example: src="/var/www/myproject/images/logo.png" if image is on the same server. If image is from external server src is absolute path example: src="https://www.google.bg/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png". Hope this will help someone.

    0 讨论(0)
提交回复
热议问题