Closed ghost closed 9 years ago
Hello ! Can you paste me here the code used ?
Oh I see the problem. When your template is generated, the path of the image is relative to where you are on the website. Html2pdf isn't in that web context and does not know your current location, it can't resolve relative pathes this way.
You should try {{ asset('bundles/bdocdemo/images/'~logo, absolute=true) }}
that would make your asset url absolute (and so reachable by the library).
Another method is to develop your own twig function that resolve an asset to its full path on your server (/var/www/...../logo.png
or C:/wamp/..../logo.png
).
Sorry for the delay in the response, I hope it still helps you !
Hi,
got this problem before
2 ways :
1) same as @OwlyCode (<img src="{{ asset('images/logo.png', absolute=true) }}" />
) (may not work if your server block some ports)
2) ./images/logo.png
should be well resolved (I often use this way, note the image is not symlinked, and ./ is in fact the /web/ symfony folder)
sorry but the two way not working :
1) same as @OwlyCode () (may not work if your server block some ports)
i have the error : Unknown argument "absolute" for function "asset(path, package_name)" in OCBdocBundle:Default:pdfafficheimage.html.twig at line 7.
and for the : 2) ./images/logo.png should be well resolved (I often use this way, note the image is not symlinked, and ./ is in fact the /web/ symfony folder)
i have this error :
my pdf out but without image
Which version of Symfony are you using ? The absolute url for assets was introduced in 2.4 if I rember well. (see there : https://github.com/symfony/symfony/commit/76b88511a683acaf8d7e3f6ad379a8e9e5bd669c )
In fact it was introduced in 2.5. Are you using the LTS version ?
Hello,
well i have this error message :
ERREUR n°6 : Impossible de charger l'image /html/demoPDF/Symfony/web/bundles/demo/images/logo.png 500 Internal Server Error - HTML2PDF_exception
but when in lunch the model in html format the image is found
so why html2pdf can't see the image ?