I am using rails 4. I want to display an image in pdf, so I install prawn gem file and my code is
def index
text "something"
image "#{Rails.root}/images/logo.jpg"
end
but i getting an error as undefined method image
Yes, prawn give undefined method image. So you can use this way.
In test.pdf.prawn file.
pdf.image "#{Rails.root}/images/logo.jpg"
You can also apply position and width to as:
pdf.image "#{Rails.root}/images/logo.jpg", :at => [50,450], :width => 450
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With