title: Problem generating pdfs with acts_as_flying_saucer
body: <p>I'm using the rails plugin acts_as_flying_saucer to generate a pdf, but the pdf doesn't work:  i can save it ok, but when i try to open it i get this error message:</p>
  
  <pre><code>Unable to open document
  File type SOR File (text/plain) is not supported
  </code></pre>
  
  <p>Here's my set up.  I'm using rails 2.3.4 and the latest version of the acts_as_flying_saucer plugin.  I have this route:</p>
  
  <pre><code>  map.all_help '/help/all.:format', :controller =&gt; "help", :action =&gt; "all"
  </code></pre>
  
  <p>which goes to this controller action:</p>
  
  <pre><code>class HelpController &lt; ApplicationController
    acts_as_flying_saucer    
  
    def all
      respond_to do |format|
        format.html {
          render :action =&gt; "all", :layout =&gt; "help_pdf"
        }
        format.js
        format.pdf {
          render_pdf :template =&gt; 'help/all.html.erb', 
                     :layout =&gt; "help_pdf",
                 :send_file =&gt; { :filename =&gt; "my-filename.pdf",  :type =&gt; "application/pdf"}      
        }
      end    
    end
  
  end
  </code></pre>
  
  <p>and i also have this mime type defined:</p>
  
  <pre><code> Mime::Type.register "application/pdf", :pdf
  </code></pre>
  
  <p>When i go to the page, /help/all.pdf, it generates a 0 byte pdf (which i can save ok) and i get the error message from the top of this post when i try to open it.</p>
  
  <p>Going to the standard web page version of the page (/help/all) works fine.  I thought maybe my java vm wasn't set up but it seems to be fine:</p>
  
  <pre><code>max-laptop:millionaire[subjects]$ java -version
  java version "1.6.0_20"
  Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
  Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
  </code></pre>
  
  <p>I'm out of ideas at this point...grateful for any advice! max</p>
  
  <p>EDIT: Just noticed that a bunch of error output is in my mongrel-running tab:</p>
  
  <pre><code>ERROR:  'Premature end of file.'
  Exception in thread "main" org.xhtmlrenderer.util.XRRuntimeException: Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException: Premature end of file.
      at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:191)
      at org.xhtmlrenderer.resource.XMLResource.load(XMLResource.java:71)
      at org.xhtmlrenderer.swing.NaiveUserAgent.getXMLResource(NaiveUserAgent.java:205)
      at org.xhtmlrenderer.pdf.ITextRenderer.loadDocument(ITextRenderer.java:102)
      at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:106)
      at Xhtml2Pdf.main(Xhtml2Pdf.java:19)
  Caused by: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Premature end of file.
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:719)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
      at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:189)
      ... 5 more
  Caused by: org.xml.sax.SAXParseException: Premature end of file.
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:636)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:707)
      ... 7 more
  </code></pre>
  
  <p>I'm wondering now if there's something wrong with the page i'm trying to convert to pdf.  I ran the html version of the page past the w3c validator and the page validates ok.    So now i'm stumped again...</p>
  
  <p>EDIT 2: i think i'm getting closer now:  looking in my log, i see</p>
  
  <pre><code>Rendering help/all.html.erb
  html file: /tmp/ff4c8ff01d544500ea4bfea43e6108c1.html
  Sending X-Sendfile header /tmp/ff4c8ff01d544500ea4bfea43e6108c1.pdf
  </code></pre>
  
  <p>So, i'd expect /tmp/ff4c8ff01d544500ea4bfea43e6108c1.html to have the html version of my page in it, but it's just a four line empty text file.  No wonder flying saucer can't convert it.   I don't know why it's saving an empty html file though.</p>
  
  <p>EDIT 3: here's the html i'm currently trying to convert</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
        &lt;title&gt;Help for Millionaire For Schools&lt;/title&gt;
    &lt;/head&gt;
  
    &lt;body class="pdf"&gt;
          &lt;div id="bgeffect"&gt;&lt;/div&gt;        
  
      &lt;div id="pageWrapper" class="mainHelpPages"&gt;
  
        &lt;div id="helpContent"&gt;
          &lt;div id="helpPane"&gt;
            &lt;div class="inner"&gt;
              &lt;p&gt;Welcome to my pdf&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;      
      &lt;/div&gt; 
  
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>