Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert image in pdf using prawn

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

like image 834
Antony Mithun Avatar asked Sep 18 '25 00:09

Antony Mithun


1 Answers

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    
like image 61
Piyush Awasthi Avatar answered Sep 20 '25 16:09

Piyush Awasthi