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?
我在Rails中使用PDFKit,它显示来自db的表。我希望每个表都有单独的页面。我如何做到这一点?
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
1 个解决方案
#1
3
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.
好吧,我不确定这是不是你想要的但它确实是最值得考虑的。您也可以使用wickedpdf,然后在您的CSS中围绕您的内容和以下内容包装div。
div.page {
width: 180mm;
height: 277mm;
overflow: hidden;
page-break-after: always;
}
#1
3
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.
好吧,我不确定这是不是你想要的但它确实是最值得考虑的。您也可以使用wickedpdf,然后在您的CSS中围绕您的内容和以下内容包装div。
div.page {
width: 180mm;
height: 277mm;
overflow: hidden;
page-break-after: always;
}