邪恶的pdf呈现两页的最后一行 [英] Wicked pdf rendering the last row across two pages
问题描述
我正在使用 wicked_pdf 生成pdf.我面临的问题是,有时会在两页之间显示该页的最后一行.是否有一种方法可以告诉wicked_pdf无法容纳该页面中的整个行,或者无法限制该页面中的行数?
I am using wicked_pdf to generate pdfs. The problem i am facing is that, sometimes it displays the last row in the page across two pages. Is there a way to tell wicked_pdf to render the row in next page if it can't fit the entire row in that page or set a limit on the number of rows in a page?
下面的图片是我遇到的一个问题.
Below image is an example of my problem.
我的选择是
render :pdf => file_name,
:layout => "pdf.html",
:disposition => "attachment"
推荐答案
由于WickedPDF实际上并未创建表(仅从html/css渲染表),因此可用的选项不多-您可以尝试使用
Since WickedPDF isn't actually creating a table (just rendering one from the html/css) there aren't many options available - you can try using page-break-inside: avoid;
in your css, you may also need to manually break down the sizes of the tables so that the effect of avoiding page breaks isn't too severe.
css:
table, tr, td, th, tbody, thead, tfoot {
page-break-inside: avoid;
}
至少,这应该可以帮助您入门.
That should get you started, at least.
Here is another question on this subject with some further info: How to avoid page break inside table row for wkhtmltopdf
这篇关于邪恶的pdf呈现两页的最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!