# Anyone used acts\_as\_flying\_saucer? problem with pdf\_file

**URL:** <https://www.ruby-forum.com/t/anyone-used-acts-as-flying-saucer-problem-with-pdf-file/173232>\
**Category:** Rails\
**Created:** [August 5, 2009, 11:21am UTC](https://www.ruby-forum.com/t/anyone-used-acts-as-flying-saucer-problem-with-pdf-file/173232 "2009-08-05T11:21:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [August 5, 2009, 11:21am UTC](https://www.ruby-forum.com/t/anyone-used-acts-as-flying-saucer-problem-with-pdf-file/173232/1 "2009-08-05T11:21:49Z")

</div>

hey all

I’m trying to use the plugin acts\_as\_flying\_saucer, which converts html  
(well, xhtml, strictly speaking) to pdf.

> **[GitHub - dagi3d/acts\_as\_flying\_saucer: acts\_as\_flying\_saucer is a Ruby On Rails...](https://github.com/dagi3d/acts_as_flying_saucer/tree/master)**
>
> master

It works if i choose the method which saves a file to my local hd, but  
it doesn’t work if i choose the method which sends a file to the  
browser: the file that comes through has a size of 1 byte and can’t be  
opened.

I’m following the examples on the above page and as far as i know have  
checked all the right boxes. Here’s my code -

This works:

```
    render_pdf :template => 'school_subscribers/show_pdf',
               :pdf_file => '/home/max/Desktop/saved.pdf'

```

And this doesn’t work (sends an empty file):

```
    render_pdf :template => 'school_subscribers/show_pdf',
               :send_file => { :filename => "pushed.pdf" }

```

Does anyone have any experience with, or insight into, this by any  
chance?

thanks  
max

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [August 5, 2009, 1:28pm UTC](https://www.ruby-forum.com/t/anyone-used-acts-as-flying-saucer-problem-with-pdf-file/173232/2 "2009-08-05T13:28:48Z")

</div>

Tracked this down to a problem with x\_sendfile - i needed to set it to  
false in order to get it working. Here’s my current call:

render\_pdf :template =\> ‘school\_subscribers/show\_pdf’,  
:send\_file =\> { :filename =\> filename,  
:x\_sendfile =\> false,  
:disposition =\> “inline”,  
:type =\> “application/pdf”}

I don’t know why x\_sendfile is going wrong - it misbehaves the same way  
in my local single mongrel setup, my local apache&mongrel setup and our  
staging server which is apache with multiple mongrels. I don’t know  
much about x\_sendfile but even my much more knowledgeable colleague is  
stumped.
