html - WkHTMLtoPDF not loading local CSS and images -
i've seen multiple questions similar one, hesitant @ first post it. nothing suggested resolved issue , can't seem figure out what's wrong myself.
for project made 1 client wanted ability convert quotes customers (generated using online form) pdfs. simple enough. entire project in php, used following simple process:
- save quote temporary html file
- use wkhtmltopdf convert html file pdf
- output pdf file
- clean (delete temporary files)
this worked until changed servers. new server has firewall.
at first pdf conversion step returning firewall page saying server couldn't make outbound connections. resolve fed html file directly instead of linking (/var/www/mysite/temp/18382.html instead of www.example.com/temp/18382.html). converted html, firewall prevented loading of css , images
i can overcome css embedding directly in site instead of linking (using <style>
tags), doesn't work images
i tried using relative links first. changed <img src="http://www.example.com/temp/image.jpg" />
<img src="./image.jpg" />
. didn't work.
next tried <img src="file:///var/www/mysite/temp/image.jpg" />
didn't work, either
i read around , through wkhtmltopdf manual , tried several different command line arguments --enable-local-file-access
, --enable /var/www/mysite/temp/
, , --images
nothing seems fix it
if on linux check ownership of images. windows find info on http://code.google.com/p/wkhtmltopdf/wiki/usage.
i tried different kind of paths image:
<img src="file:///var/www/testpdf/flowers.jpg"><br>
<img src="./flowers.jpg"><br>
<img src="flowers.jpg"><br>
<img src="/var/www/testpdf/flowers.jpg"><br>
all images showed correct. didn't use command line arguments (only wkhtmltopdf /var/www/testpdf/makepdf.html makepdf.pdf
)
Comments
Post a Comment