views:

43

answers:

1

Hi there,

I'm using Prawnto to generate PDFs in my Rails app. I want three specific options set for my PDFs:

  • I don't want it to start with a blank page
  • I want it to download directly (not inline)
  • I want to specify the filename

Here's my controller method:

def print
    @purchase = Purchase.find(params[:id])
    prawnto :prawn=>{:skip_page_creation=>true}, :inline=>false, :filename=>@purchase.deal.name + "-" + @purchase.customer.name+".pdf"
end

Without the :skip_page_creation option, the other two options (inline and filename) work fine. But when I add the skip_page_creation option, it goes inline with a default filename. And of course, if I remove skip_page_creation, I get a nice downloaded PDF with a first blank page.

The docs for this library leave something to be desired, but can anyone point me in the right direction?

Cheers!

Aaron.

A: 

I've just tried this by changing one of my inline examples which worked ok:

module SharedPdfs    
  def show
    prawnto :prawn => {:skip_page_creation=>true}, :inline => false, :filename => "results_pdf.pdf"
    render :template => '/results/show'
  end
end

Had a quick look at the prawnto source and it should pickup your prawn options not sure why it isn't but at least you've got it working for now.

tsdbrown