zakird / wkhtmltopdf_binary_gem

Ruby gem containing easily installable access to wkhtmltopdf application
https://rubygems.org/gems/wkhtmltopdf-binary
Apache License 2.0
184 stars 346 forks source link

Error with local image in new versions #93

Closed thib44 closed 3 years ago

thib44 commented 4 years ago

When I try to display an image in a pdf, i've got a square, instead of the image. No problem with the '0.12.5.4' version, but the issue is with the upper versions. Example of code : <%= wicked_pdf_image_tag 'logo_lifen_invoice.png' %> And i'm using the pdf_from_string method.

bertiecroll commented 4 years ago

For info incase anyone is still having problems with this. I had run into a similar issue, rather than being an issue with this gem there was a breaking change with wkhtmltopdf in it's 012.6 release which now blocks local filesystem access by default.

To resolve the issue, you may want to look at the advanced options on the wicked_pdf gem and use enable_local_file_access. More info in the docs.

Hope that helps!

unixmonkey commented 4 years ago

Thanks for pointing this out. The work-around for wicked_pdf is to put it in your initializer like this:

WickedPdf.config = {
  enable_local_file_access: true
}

Which should apply that command-line flag to all calls.

pedrofurtado commented 3 years ago

@unixmonkey That's right, in 0.12.6 version of wkhtmltopdf the filesystem access is blocked by default, but is possible to reactivate it by command-line flag, as mentioned by @unixmonkey and @bertiecroll .

So, I think we solved and the issue can be closed 🎉