Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prawn - import image from URL

I can't seem to figure out how to import an image from an url

To import the images from my localhost I use:

image"./assets/images/img.png"

When I replace the path with an URL it says

`image' : URL not found

Is there a solution for this, or should I create a def that downloads the image and to use the path it returns?

like image 202
Wijnand Avatar asked Jul 19 '12 12:07

Wijnand


1 Answers

you need to do the following -

require "open-uri"

Prawn::Document.generate(INSERT_YOUR_PDF_FILENAME_HERE) do 
   image open(INSERT_YOUR_URL_HERE)
end

Refer to http://rubydoc.info/gems/prawn/0.12.0/frames for more details.

like image 160
saihgala Avatar answered Oct 14 '22 08:10

saihgala