ruby-on-railsimagewicked-pdf

wickedpdf not rendering images?


i am using wickedpdf gem to generate pdf invoice from the html code.

gems:

gem 'wicked_pdf'
gem "wkhtmltopdf-binary"

gemfile.lock

wicked_pdf (1.0.6)
wkhtmltopdf-binary (0.9.9.3)

in controller:

  def show_pdf_invoice
    respond_to do |format|
      format.html { render :layout => "pdf.pdf.erb" }
      format.pdf do
    render pdf: "show_pdf_invoice", :layout => 'pdf.pdf.erb'
    #render :pdf => "pdf"#, :layout => 'pdf.html.erb'
      end
    end
  end

in views/invoices/show_pdf_invoice.pdf.erb

  <img id="image" src="https://www.google.co.in/logos/doodles/2016/holidays-2016-day-2-6356741311692800-scta.png" alt="logo" /> 
  <%= wicked_pdf_image_tag 'https://www.google.co.in/logos/doodles/2016/holidays-2016-day-2-6356741311692800-scta.png' %>

pdf is getting generated. But the images are not showing. in the place of images empty boxes are coming. unable to find the issue.


Solution

  • I've had the same problem, mine was fixed by removing https for http. Have you tried this? and for the Amazon S3 part: You could use gsub for that as in: gsub("https", "http")