Question

I am using Prawn 0.12.0 in a Rails 3.2.12 app.

If I have an image on my local server it can show in a standard rails view, and I can also have it shown in a Prawn PDF using the following code

@logo = company.logo_url(:large).to_s    
image @logo, :fit => [83.mm, 26.mm]

So far, so good. If I change the location of the image to be on Amazon S3 I get the following

I am able to show in a standard Rails view no problem If I try to display the image in a Prawn pdf I get the following error

Argument error (https://mydomain.s3.amazonaws.com/uploads/company/logo/20/large_2275_logo.png not found):

And if I then copy and paste that url into a browser, the image shows fine.

So to recap...

  1. I am able to use the Prawn image command for a local image, indicating I am using the Prawn syntax correctly
  2. I can access an image on Amazon S3 using a direct browser and a Rails view, indicating that the URL is correct
  3. BUT, I can not access the image on Amazon S3 from Prawn

Has anyone seen anything similar, or have any suggestions?

Michael

Était-ce utile?

La solution

I had the same problem, I've solved with

require 'open-uri'

image open("hxxp://www.thesite.com/theimage.png")

Autres conseils

With the recent releases of Prawn, you can achieve loading remote images without requiring open-uri;

image open("http://example.com/remote_image.pdf"), at: [300, 100], width: 100, height: 100
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top