【问题标题】:Start a New Page with PDFKit including Table headers使用包含表格标题的 PDFKit 开始一个新页面
【发布时间】:2016-02-03 05:20:32
【问题描述】:

我在 Rails 中使用 PDFKit 来显示我的数据库中的表记录。我想在当前页面没有空间时显示新页面继续记录以及表头。我怎样才能做到这一点?

    html_content = render_to_string(:template => "example/pdf_example.html.erb",:layout => false)
    pdf_convert = PDFKit.new(html_content, :margin_right => '0.1in',:margin_left => '0.1in',:margin_top => '0.1in',:margin_bottom => "0.1in",:page_size => "A4", :orientation => 'landscape')

    report_name = "example report"
    send_data(pdf_convert.to_pdf,:filename=>"#{report_name}.pdf")

【问题讨论】:

    标签: ruby-on-rails-4 pdf wkhtmltopdf pdfkit


    【解决方案1】:

    您可以使用“wicked_pdf”将html页面转换为所有html样式的pdf。

    <% if params[:format] == "html"%>
      <%= render template: "reports/term_loan_report_data_header.html.erb"%>
    <%end%>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-18
      • 2014-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多