Closed SalvesTestservices closed 6 years ago
It might still be access rights. How does your app authorize this, or is it open to the world?
Create an html file on your filesystem with this:
<!doctype html>
<html>
<head><title>test</title></head>
<body>
<h1>test</h1>
<img src="https://myblob.blob.core.windows.net/foldername/image.jpg">
</body>
</html>
Does it still work?
Yes that does work, these images are open to the world.
Would you mind sharing one such image that definitely doesn't PDF for you, and what versions of wicked_pdf and wkhtmltopdf you are using?
The only thing I can think of right now, is maybe they are being served over SSLv3, and you are on a somewhat out-of-date wkhtmltopdf
. You can see this thread for more details on that if you want to go down that debugging path.
The wicked_pdf version is 1.1.0
. I'm not sure which version of wkhtmltopdf
is being used on Heroku, I don't know ho to get that version number.
Are you using wkhtmltopdf-heroku
or wkhtmltopdf-binary-edge
or something like that in your Gemfile/Gemfile.lock? What version of that are you using? If you can't find out that way (custom binary added to a buildpack), then you should be able to run wkhtmltopdf --version
to find out.
I forgot to use these gems, so I did that and deployed to Heroku, but still the images are not rendered. I use these gems:
wkhtmltopdf-binary-edge (0.12.5.0)
wkhtmltopdf-heroku (2.12.2.4)
Maybe a buildpack I should be using on Heroku?
Sorry, closed it by accident :-)
For me at the moment this solves the issue, as found in #344:
<%= image_tag image_url.gsub('https', 'http') %>
This makes me fairly certain it's one of these 2 things:
The server you are requesting images from is sending over SSLv3, which is susceptible to the POODLE attack, so they are untrusted by wkhtmltopdf.
There may be a certificate issue with the HTTPS. If you need to supply your own cert there are flags you can pass wkhtmltopdf
to supply your own.
If you must request your content over http, I would suggest a small change to your fix:
image_url.gsub(/\Ahttps/, 'http')
That regex anchors the replacement to the beginning of the string, so if there's somehow an https
somewhere in the middle of your image_url
, it won't replace them all, just the one on the beginning.
In my PDF I want to show an image, which is stored in an Azure blob. I have added this:
image_tag("https://myblob.blob.core.windows.net/foldername/image.jpg")
When I generate the PDF on my local environment it works fine, but when I generate the same PDF in production (Heroku), it doesn't show the image. Also
wicked_pdf_image_tag
is not working. What could be the problem?It cannot be the access rights, because when I enter the image URL in a browser it shows the image.