0

I am having very difficulties to display images on production. The images are showing perfectly fine in local development but once it goes to production, it displays nothing. There are a few lines of code I have tried

System.pdf.erb

#1
<img src="'<%= url_for(system.last.image)%>"> <br><br><hr>

#2
<%= wicked_pdf_image_tag 
system.last.image.service_url.gsub("https", "http") %>


#3
<%= wicked_pdf_image_tag 
system.last.image.service_url.gsub("https", "http") %>


#4
<img src="<%= system.last.image.variant(resize: 
"590").processed.service_url %>">

Gemfile

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

None of above works. Please help.

Unixmonkey
  • 18,485
  • 7
  • 55
  • 78
  • 1
    in console, try Net::HTTP.get_response(URI.parse(system.last.image.service_url.gsub("https", "http"))) and see if anything prevents pulling the data in your production server. if no issue, try downloading and saving image in temp directory and include each time generating pdf – dileep nandanam Jun 11 '19 at 11:28
  • I'm not super-familiar with ActiveStorage, but it is set up to provide links that hide the actual source of the content and redirect to the real location. It seems that wkhtmltopdf has issues with redirects to content (https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2346). You might try building a helper that does something like this (https://stackoverflow.com/a/4867915/23915) to get the real final URL and use that. – Unixmonkey Jun 11 '19 at 14:51

0 Answers0