Closed evilito closed 7 years ago
The problem was that mpdf doesn't understand well relative paths for images, even if the web browser is fine with them and display the images correctly.
The fix was to generate a path with an absolute base URL, in this case, by setting the second parameter of the "Url::to" function to true, as per the documentation.
<img src="<?= \yii\helpers\Url::to('@web/images/logo.png', true) ?>" width="100" alt="logo" />
I hope this helps others having the same issue. Thank you.
The absolute URL didn't solve this problem to me. But using base64 image instead solve it.
I had the same problem. The absolute URL and base64 -- didn't work.
You can set $this->_mpdf->showImageErrors = true;
in file ... /vendor/kartik-v/yii2-mpdf/Pdf.php in method setApi(). Then you can see the error.
In my case, I had issues with gd (Error parsing image file - image type not recognised, and not supported by GD imagecreate). I changed picture and it helped.
My problem was a different one and i had problem in local server as well as in the hosting server. I solved problem with a shortcut that I copied the images to web folder instead of database. After the change the application worked without issues.
The absolute URL and base64 -- didn't work me too. I install php5-gd and this solved my problem.
HI, just try to install php7.0-gd http://stackoverflow.com/a/22575654/6547455
Hi, just clean browser history or update browser.
Inside the MPDF directory there is a subdirectory "tmp", you need to give write permissions to it.
i have problem in uploading the img in yii2, my yii2 framework is in latest version. And i have uploaded some img in home page using code (src="img/product.jpg") and it's working but when i click on another page and come back to the home page , the img is not displaying and it needs code (src="../img/product.jpg") to display it on home page. so why is that? please help me solve this problem.
I had a same problem because of SSL error!
If peer verification fails in ssl hand shake, it will not show the image.
I 'm using 8.0.15
version of mpdf, in getImage()
function of vendor/mpdf/mpdf/src/Image/ImageProcessor.php
the file_get_contents
is used and there is no way to pass context options.
Hello, I have a couple of simple PNG images in a view print.php, like this:
In the local environment, the images shows fine in the generated PDF and even if I just print it without PDF (controller code):
However, on the production server, the images are not showing. They show only if I print the view without PDF (like in the previous code), so for me this means that the images are fine, no broken links (because they show on renderPartial) and leads me to think that there might be some issue with the mpdf?
The generated PDF in the production server shows a red "X" where the image should be loaded. How can I troubleshoot this? Can the PDF be examined? If it was an HTML page I would check where the link in "src" is leading, but in the PDF I'm not sure how to proceed.
Local environment is PHP 5.5 and production is PHP 5.6. Does this has something to do?
Any help will be really welcomed and appreciated!