문제

I'm using PDFKit in Rails that displays tables from my db. I want each table to have its own separate page. How can I achieve this?

html = "<p>HTML content here</p>"

kit = PDFKit.new(html, :page_size => 'Letter')
  output = kit.to_pdf

respond_to do |format|

format.pdf do
  send_data output, :filename => "trading_analysis.pdf",
                    :type => "application/pdf"
  end
end
도움이 되었습니까?

해결책

Okay not sure if this maybe what you are exactly looking for but it is certainly most worth considering. You could alternatively look at using wickedpdf and then wrapping a div around your content and the following in your CSS.

div.page {
  width: 180mm;
  height: 277mm;
  overflow: hidden;
  page-break-before: always;
}

EDIT: page-break-after: always; added a blank page at times, so we should use page-break-before: always;

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top