开发者

Problems with Prawnto options

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜