# Pdf writer not finding public directory

**URL:** <https://www.ruby-forum.com/t/pdf-writer-not-finding-public-directory/67653>\
**Category:** Rails\
**Created:** [September 5, 2006, 11:00pm UTC](https://www.ruby-forum.com/t/pdf-writer-not-finding-public-directory/67653 "2006-09-05T23:00:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jazzlover2002](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@jazzlover2002](https://www.ruby-forum.com/u/jazzlover2002)\
**Post date:** [September 5, 2006, 11:00pm UTC](https://www.ruby-forum.com/t/pdf-writer-not-finding-public-directory/67653/1 "2006-09-05T23:00:34Z")

</div>

Hi all,

I’m attempting to learn about PDF::Writer. I’ve written a brief test  
program  
to play with the concepts. Here is the code:

```
pdf = PDF::Writer.new
pdf.select_font "Times-Roman"
pdf.text "Hello, Ruby.", :font_size => 72, :justification =>

```

:center

```
pdf.save_as("#{@request.relative_url_root}/pdf/hello.pdf")

```

I keep getting the following error:

(Note: schedprog is an alias to my rails application directory (which  
is /pds)

Errno::ENOENT (No such file or directory - /schedprog/pdf/hello.pdf):

I’ve tried a number of options, but no matter what I do I get the above

error message. I’ve checked the application’s public directory and  
know  
the pdf directory exists and I even set permissions to 777 just to  
make sure my program could do anything.

What am I missing? Any help would be appreciated.

Dave  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![jazzlover2002](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@jazzlover2002](https://www.ruby-forum.com/u/jazzlover2002)\
**Post date:** [September 5, 2006, 11:28pm UTC](https://www.ruby-forum.com/t/pdf-writer-not-finding-public-directory/67653/2 "2006-09-05T23:28:39Z")

</div>

You have two different urls you have to keep in mind. Your site url,  
which  
is handled by your request, and you url on your server, or more  
accurately  
your path. When you ask you’re request what the url is, it’s looking at  
what path the browser would be looking at. You need to be worried about  
the  
server side. It should be just as easy as setting your path to  
./public/pdf/hello.pdf, assuming that you’re trying to get into your  
local  
project’s public file.

On 9/5/06, jazzlover2002 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> pdf.text "Hello, Ruby.", :font_size => 72, :justification =>
> 
> ```
> 
> removed\_email\_address@domain.invalid
> 
> >

–  
Mike W.  
Web D.  
UW-Eau Claire

---

<div class="post-metadata">

**Author:** ![jazzlover2002](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@jazzlover2002](https://www.ruby-forum.com/u/jazzlover2002)\
**Post date:** [September 8, 2006, 4:20pm UTC](https://www.ruby-forum.com/t/pdf-writer-not-finding-public-directory/67653/3 "2006-09-08T16:20:19Z")

</div>

On 5 Sep 2006, at 21:52, jazzlover2002 wrote:

> :center  
> I’ve tried a number of options, but no matter what I do I get the  
> above
> 
> error message. I’ve checked the application’s public directory and  
> know

I don’t see what the public directory has to do with it - if /  
schedprog/pdf/hello.pdf is what the error message says, that’s what  
it’s looking for - the error message doesn’t mention ‘public’, so it  
isn’t looking there.

/ - root directory  
/pdfs - your rails application root directory (seems a bit odd to  
have this under /, but never mind)  
/app - your model classes etc  
/pdf - this is where PDF:;Writer is trying to put the PDF  
/public - the rail public dir  
/pdf this is where you want the PDFs to go

Ben

> the pdf directory exists and I even set permissions to 777 just to  
> make sure my program could do anything.
> 
> What am I missing? Any help would be appreciated.

–  
Ben B. - Director  
Airsource Ltd  
Tel: 01223 708370 / 07786 916043

---

<div class="post-metadata">

**Author:** ![jazzlover2002](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@jazzlover2002](https://www.ruby-forum.com/u/jazzlover2002)\
**Post date:** [September 11, 2006, 3:00pm UTC](https://www.ruby-forum.com/t/pdf-writer-not-finding-public-directory/67653/4 "2006-09-11T15:00:12Z")

</div>

the only files that are publicly accessible by the server are files in  
your  
public folder. That’s why your stylesheets, javascripts, and images  
folders  
are all in this folder. So if you go to  
[http://www.mysite.com/images/image1.jpg](http://www.mysite.com/images/image1.jpg), it is looking on the server at  
location rails\_app/images/image1.jpg. So if you want to be able to get  
to a  
pdf by going to htttp://www.mysite.com/pdfs/pdf1.pdf, you would have to  
save  
pdf1.pdf in rails\_app/pdfs/pdf1.pdf

On 9/8/06, Ben B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > to play with the concepts. Here is the code:  
> > (Note: schedprog is an alias to my rails application directory (which  
> > I don’t see what the public directory has to do with it - if /  
> > /pdf this is where you want the PDFs to go  
> > –

–  
Mike W.  
Web D.  
UW-Eau Claire

---

<div class="post-metadata">

**Author:** ![jazzlover2002](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@jazzlover2002](https://www.ruby-forum.com/u/jazzlover2002)\
**Post date:** [September 11, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/pdf-writer-not-finding-public-directory/67653/5 "2006-09-11T17:58:36Z")

</div>

Thanks, Mike.

I finally got there. My problem was with a redirect I was doing  
after I created the pdf file. I discovered I was pointing to the  
wrong place. So for a while I was looking in the wrong place for a  
solution. Wasn’t quite awake as I thought I was on this one. 🙂

Dave

On Sep 11, 2006, at 5:45 AM, Mike W. wrote:

> On 5 Sep 2006, at 21:52, jazzlover2002 wrote:
> 
> > ```
> > pdf.select_font "Times-Roman"
> > 
> > ```
> 
> schedprog/pdf/hello.pdf is what the error message says, that’s what
> 
> Ben B. - Director  
> Airsource Ltd  
> Tel: 01223 708370 / 07786 916043
> 
> >

Dave Pancost  
removed\_email\_address@domain.invalid
