ruby-on-railswkhtmltopdfwicked-pdf

ROR: Image not getting rendered in wicked_pdf's pdf


Here I am not talking about the images with wicked_pdf_image_tag. Those are working well. But when I download the pdf then it isn't rendering the image.

It is rendering like a small box. Click here

File.html.haml

%img{src: "/assets/#{CONFIG[$skey]['main_logo_path']}"}

File.pdf.erb

<%= wicked_pdf_image_tag(CONFIG[$skey]['main_logo_path'],alt: "Logo", class: "mt-md mb-md")  %>

Gems used:

wicked_pdf (2.1.0)
wkhtmltopdf-binary (0.12.6.5)

Please help!


Solution

  • If someone is still searching for the solution of this issue. Here is the answer:

    <%= image_tag wicked_pdf_asset_base64("logo.png") %>
    

    Use image_tag wicked_pdf_asset_base64 for the images that are present in assest/images folder.