ald*_*n.h 3 ruby-on-rails wicked-pdf ruby-on-rails-4
我在生成报告的Rails应用程序中使用gem wiked_pdf。
但是当超过1页时,我无法解决数据中断问题。
我尝试了很多时间来调整边距或间距,但仍然无法解决。
respond_to do |format|
format.html
format.pdf do
render title: @report_title,
pdf: @report_title,
template: 'applicants/generate_report.pdf.erb',
encoding: 'UTF-8',
orientation: 'Landscape',
layout: 'pdf_template.html',
footer: {
center: '[page] of [topage]',
right: "",
font_name: 'Arial',
font_size: 8
},
margin: {
top: 10, # default 10 (mm)
bottom: 12,
left: 7,
right: 7
},
spacing: 0
end
end
Run Code Online (Sandbox Code Playgroud)
我也尝试应用CSS,例如:
@media print {
td, tr {page-break-inside: avoid; }
table.full_report_table>tbody>tr>td {page-break-inside: avoid !important; }
}
Run Code Online (Sandbox Code Playgroud)
没用!
请帮忙!
解决了
是的,
page-break-inside:避免;
它在div标签中正常工作。
但是花了我一段时间,并进行了粗略的研究,以弄清楚如何使其与 长桌一起使用。
添加一些CSS样式可以帮助我解决问题。
就像在文档W3 page-break中一样,它将与block元素一起使用。
我所做的就是将显示样式与其一起添加。
<tr style="page-break-inside: avoid; display: inline-table;">
Run Code Online (Sandbox Code Playgroud)
在我的情况下,内联表或内联块都可以。
我希望这将对其他遇到与我相同的错误的人有所帮助。
| 归档时间: |
|
| 查看次数: |
2434 次 |
| 最近记录: |