-->

wkhtmltopdf自动分页符(wkhtmltopdf automatic page breaks

2019-07-30 14:35发布

我使用wkhtmltopdf v0.11.0 RC1通过Rails应用程序wicked_pdf (我知道wicked_pdf不支持新的命令行参数的符号,我用我自己的宝石叉)。 我认为,一个页面内没有安装含量应自动溢出到下一个,但这种情况并非如此 - 我看到的文字只是被切断,有时在一条线的中间。

我知道我可以用我的布局页page-break-after:always ,但是这看起来脏脏的硬编码,并且除了HTML来自ERB模板所以它并不总是显而易见放在哪里分页符。

可问题采取行动,使分页符自动插入? 我失去了一些关于如何工作的?

下面是生成的命令行的样子

\"c:/program files (x86)/wkhtmltopdf/wkhtmltopdf.exe\"
   --header-html \"file:///C:Users/bleak/AppData/Local/Temp/campaign_report.header.pdf_pdf_1580_0.html\" 
   --footer-html \"file:///C:/Users/bleak/AppData/Local/Temp/campaign_report.footer.pdf_pdf_1580_0.html\"
   --margin-top 20 --margin-bottom 15 --margin-left 5 --margin-right 40
   --page-size \"A4\"   
   page \"file:///C:/Users/bleak/AppData/Local/Temp/campaign_report_cover.pdf_pdf_1580_0.html\" --disable-javascript  
   toc --xsl-style-sheet \"c:/work/morizo/admoney/app/views/layouts/campaign_report.xsl\"  - - 

Answer 1:

原来,这是发生由于固定的尺寸上div š用来包裹文档部分:

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

一旦我删除widthheight ,自动断开始按预期工作。 简单。



文章来源: wkhtmltopdf automatic page breaks