# Serving a PDF document

**URL:** <https://www.ruby-forum.com/t/serving-a-pdf-document/150502>\
**Category:** Rails\
**Created:** [October 9, 2008, 8:59am UTC](https://www.ruby-forum.com/t/serving-a-pdf-document/150502 "2008-10-09T08:59:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijomo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@sijomo](https://www.ruby-forum.com/u/sijomo)\
**Post date:** [October 9, 2008, 8:59am UTC](https://www.ruby-forum.com/t/serving-a-pdf-document/150502/1 "2008-10-09T08:59:14Z")

</div>

Hi all,

Been banging my head against this for a little while so figured I see if  
anyone here could light the way.

Our site receives input from fillable pdfs as XML (XFDF to be precise)  
and  
processes the information. We also need to be able to re-export the  
filled  
PDF. To do this you send the xfdf file with an href to the original pdf  
document.

If I point the href to a static PDF (so, put it in the public folder)  
adobe opens and fills the pdf correctly. However, if I point to the pdf  
using a dynamic URL to rails then Adobe just doesn’t fill the pdf.

So my question, what is the difference between  
[http://localhost:3000/pdfs/TACServiceReport0908.pdf](http://localhost:3000/pdfs/TACServiceReport0908.pdf) - where pdfs is a  
folder in the public folder of the app  
and  
[http://localhost:3000/forms/show/4.pdf](http://localhost:3000/forms/show/4.pdf) - this renders the exact same  
file  
using one of the following (I have tried them all)

send\_file(@form.pdf\_filename, :type =\> ‘application/pdf’, :dispoisition  
=\>  
‘attachment’)  
send\_file(@form.pdf\_filename, :type =\> ‘application/pdf’, :dispoisition  
=\>  
‘inline’)  
send\_data(content, :filename =\> filename, :type =\> “application/pdf”,  
:disposition =\> “inline”)  
send\_data(content, :filename =\> filename, :type =\> “application/pdf”,  
:disposition =\> “attachment”)

and how can I make the second method behave like the first.

Thanks  
Simon

---

<div class="post-metadata">

**Author:** ![sijomo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@sijomo](https://www.ruby-forum.com/u/sijomo)\
**Post date:** [October 9, 2008, 11:04am UTC](https://www.ruby-forum.com/t/serving-a-pdf-document/150502/2 "2008-10-09T11:04:15Z")

</div>

Simon M. wrote:

> If I point the href to a static PDF (so, put it in the public folder)  
> send\_file(@form.pdf\_filename, :type =\> ‘application/pdf’, :dispoisition =\>  
> ‘attachment’)  
> send\_file(@form.pdf\_filename, :type =\> ‘application/pdf’, :dispoisition =\>  
> ‘inline’)

I’m sorry I can’t help you directly but is the above spelling error for  
disposition actually there in your code?

---

<div class="post-metadata">

**Author:** ![sijomo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@sijomo](https://www.ruby-forum.com/u/sijomo)\
**Post date:** [October 9, 2008, 1:46pm UTC](https://www.ruby-forum.com/t/serving-a-pdf-document/150502/3 "2008-10-09T13:46:47Z")

</div>

On Thu, 09 Oct 2008 17:03:02 +0800, Mohit S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Simon M. wrote:
> 
> > Hi all,
> 
> I’m sorry I can’t help you directly but is the above spelling error for  
> disposition actually there in your code?

Yes it was, that wasn’t the problem though, once I set the :type to  
‘application/pdf’ it worked. Was sure that I had tried that at one  
stage,  
but apparently not.

Thanks  
Simon
