Rails:WickedPDF:分页符 [英] Rails: WickedPDF: Page Breaks
问题描述
在我的Ruby(1.9.2)Rails(3.0.x)中,我想使用wicked_pdf将网页呈现为PDF,并且希望控制分页符的位置.我用来控制分页符的CSS代码如下:
In my Ruby (1.9.2) Rails (3.0.x) I would like to render a web page as PDF using wicked_pdf, and I would like to control where the page breaks are. My CSS code to control page breaks is as follows:
<style>
@media print
{
h1 {page-break-before:always}
}
</style>
但是,当我使用 wicked_pdf 呈现页面时,它不会将文档分为两页.要使用wicked_pdf分页符,我还必须做些其他事情吗?
However, when I render the page with wicked_pdf, it does not separate the document into two pages. Is there something else that I must do to get page breaks with wicked_pdf?
推荐答案
由于某种原因,"@ media print"并没有完全做到这一点.我刚去了
For some reason, the "@media print" didn't quite do it. I just went with
.page-break { display:block; clear:both; page-break-after:always; }
设置CSS规则,然后在页面中粘贴以下内容以进行分页:
for the CSS rule, and then I stuck the following in my page for a page break:
<div class="page-break"></div>
那是行得通的.
这篇关于Rails:WickedPDF:分页符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!