Image not displayed - WKHTMLTOPDF

5,494 views
Skip to first unread message

prab...@gmail.com

unread,
Feb 17, 2017, 6:03:10 AM2/17/17
to jsreport
Hi Blaha,

I am testing displaying of images and have the following code in the test template with Jsrender & WKHTMLTOPDF options. While this code displays image correctly in the playground. In my local instance it only displays a small square box instead of image. This issue only occurs when I use the WKHTMLPDF option, I checked with Phantompdf, the image displays correctly.

Could you please let me if there is any config setting with respect to WKHTMLPDf that has to be set for images to be displayed correctly?


before image
after image


Please advise.

Thanks in advance

Jan Blaha

unread,
Feb 17, 2017, 8:18:42 AM2/17/17
to jsreport, prab...@gmail.com
Is it general problem of images in wkhtmltopdf or problem of this particular image? 

There is no explicit configuration needed. It works for me both on windows and linux server. I'm a bit lost.

I would recommend to find wkhtmltopdf in node_modules and try to run it on this image from command line.
Hopefully it gives some interesting information in the output.

prab...@gmail.com

unread,
Feb 17, 2017, 8:34:46 AM2/17/17
to jsreport, prab...@gmail.com
This is a general problem not specific to image. In fact in my custom template I have referred to the images under jsreport folder like this

<img src='{#image Green}'

and this image is displayed correctly. but when I refer to image like below, it just displays a square box.


can you please explain me what you mean by "try to run it on this image from command line." . I did not understand this part.

Thanks in advance

Jan Blaha

unread,
Feb 17, 2017, 8:37:50 AM2/17/17
to jsreport, prab...@gmail.com
I mean that you create a file test.html with this image reference and store it to the dir where is wkhtmltopdf installed. It should be in node_modules\wkhtmltopdf-installer\vendor\
Then you run something like

wkhtmltopdf test.html out.pdf


prab...@gmail.com

unread,
Feb 17, 2017, 8:43:52 AM2/17/17
to jsreport, prab...@gmail.com
Hi ,

Thanks for the suggestion. I tried it. &  get the below message in command prompt when I used the command below

wkhtmltopdf test.html out.pdf


Any thoughts.

Jan Blaha

unread,
Feb 17, 2017, 8:51:36 AM2/17/17
to jsre...@googlegroups.com, prab...@gmail.com
Hm, I was not lucky with searching the wkhtmltopdf issues  - https://github.com/wkhtmltopdf/wkhtmltopdf
Don't you have a proxy on the way to internet?

Maybe you would get better help in wkhtmltopdf github repository.


prab...@gmail.com

unread,
Feb 17, 2017, 8:55:25 AM2/17/17
to jsreport, prab...@gmail.com
Yes. I am in fact behind a proxy. Do I have to update any settings related to proxy?

Jan Blaha

unread,
Feb 17, 2017, 9:00:25 AM2/17/17
to jsreport, prab...@gmail.com
Please try to run wlhtmltopdf binary with option --proxy

I will add this to jsreport config if it helps

prab...@gmail.com

unread,
Feb 17, 2017, 9:09:38 AM2/17/17
to jsreport, prab...@gmail.com
Hi,
I used the proxy server name in wkhtmltopdf command prompt with --proxy & it generated the test file with the image. Thanks for your suggestion. Now how do I handle this with jsreport installation. Please advice.

Jan Blaha

unread,
Feb 17, 2017, 9:14:45 AM2/17/17
to jsreport, prab...@gmail.com
I need to implement this in the recipe, give me an hour.

prab...@gmail.com

unread,
Feb 17, 2017, 9:38:42 AM2/17/17
to jsreport, prab...@gmail.com
Great. Thanks for your help.

Jan Blaha

unread,
Feb 17, 2017, 11:45:04 AM2/17/17
to jsreport, prab...@gmail.com
Please install the latest jsreport-w...@1.2.0

Afterwards add proxy to config, see updated docs

I've also add better logging to the recipe. If you have issues the next time, try to click debug button in studio. 

prab...@gmail.com

unread,
Feb 20, 2017, 4:18:08 AM2/20/17
to jsreport, prab...@gmail.com
Hi Blaha,
 Thanks for your help. It now works as expected. I added the proxy server name in config & the image displayed as expected.

Thanks again

Jan Blaha

unread,
Feb 20, 2017, 4:19:02 AM2/20/17
to jsreport, prab...@gmail.com
Thanks for your quick test.
I'm glad it helped.
Reply all
Reply to author
Forward
0 new messages