# Prawn relative-path image

**URL:** <https://www.ruby-forum.com/t/prawn-relative-path-image/167060>\
**Category:** Ruby\
**Created:** [May 3, 2009, 1:45am UTC](https://www.ruby-forum.com/t/prawn-relative-path-image/167060 "2009-05-03T01:45:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [May 3, 2009, 1:45am UTC](https://www.ruby-forum.com/t/prawn-relative-path-image/167060/1 "2009-05-03T01:45:21Z")

</div>

Hi, I would like to show an image on PDF (via prawn pdf.image). I am  
using a photo\_for helper to retrieve an image i.e. photo\_for(@account,  
:small), which yields ![logo_small](https://www.ruby-forum.com/photos/0000/00123/logo_small.JPG?21343435445)

Is there a way to use image relative path with pdf.image? how would you  
approach this problem?

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [May 3, 2009, 2:26am UTC](https://www.ruby-forum.com/t/prawn-relative-path-image/167060/2 "2009-05-03T02:26:04Z")

</div>

On Sat, May 2, 2009 at 7:45 PM, Michael W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi, I would like to show an image on PDF (via prawn pdf.image). I am  
> using a photo\_for helper to retrieve an image i.e. photo\_for(@account,  
> :small), which yields ![logo_small](https://www.ruby-forum.com/photos/0000/00123/logo_small.JPG?21343435445)
> 
> Is there a way to use image relative path with pdf.image? how would you  
> approach this problem?

This is the wrong place to post Prawn questions. In the future, use:

[http://groups.google.com/group/prawn-ruby](http://groups.google.com/group/prawn-ruby)

Actually, Prawn has no support at all for remote images, the trick you  
may have seen in examples just uses open-uri:

require “open-uri”  
pdf.image open(“[http://foo.com/bar.png](http://foo.com/bar.png)”)

You can use this trick, but you’ll need to construct the full URL  
yourself. Prawn doesn’t know or care about the fact that you’re  
using Rails (or the web) and never will. But relative image urls for  
Rails might be useful for Prawnto, so talk to thorny\_sun about that.

-greg

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [May 3, 2009, 2:35am UTC](https://www.ruby-forum.com/t/prawn-relative-path-image/167060/3 "2009-05-03T02:35:39Z")

</div>

Thank you. In the future, definitely will post on prawn-ruby.
