PDFkit gem目录

时间:2015-12-20 13:55:26

标签: ruby-on-rails wkhtmltopdf pdfkit

使用PDFKit gem的0.8.2版,按docs中的说明传递toc会引发错误:

format.pdf {
    html = render_to_string(:action => 'pdf.html.haml')
    kit  = PDFKit.new(html, {toc: true})
    send_data kit.to_pdf, :filename => "thing.pdf", :type => 'application/pdf'
  }

我显示的一般错误,因此您可以看到toc正在wkhtmltopdf传递,而specs of the PDFkit gem建议不要{{1} }}:

--

1 个答案:

答案 0 :(得分:0)

你可以尝试

format.pdf {
    html = render_to_string(:action => '<controller_name>/action_name')
    kit  = PDFKit.new(html.to_s, toc: '')
    send_data kit.to_pdf, :filename => "thing.pdf", :type => 'application/pdf'
  }