In my twig template for generating PDF I have:
<img src="{{ asset('bundles/myBundle/images/no_avatar.jpg') }}">
While I am trying generate PDF, I am getting error:
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: getimagesize(/bundles/wrbmcisintranetsite/images/no_avatar.jpg): f
ailed to open stream: No such file or directory
Exception trace:
() at /var/www/site/vendor/tecnickcom/tcpdf/include/tcpdf_images.php:171
Symfony\Component\Debug\ErrorHandler->handleError() at n/a:n/a
getimagesize() at /var/www/site/vendor/tecnickcom/tcpdf/include/tcpdf_images.php:171
And when I change the path where this image is stored, for exmple:
<img src="{{ asset('var/storage/images/no_avatar.jpg') }}">
and copy that file without using assets:install web
it works and image is visible in output PDF file. I want to put file in MyBundle/Resources/public/images
to have it installed with assets:install
you need to pass absolute url for all assets (css included).
in your case can try with absolute_url
the as example:
<img src="{{ absolute_url(asset('images/logo.png')) }}" alt="Symfony!" />
More info in the doc here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.