8

I'm using wkhtmltopdf v0.11.0 rc1 in a Rails application through wicked_pdf (I know wicked_pdf does not support the new command line parameter notation, I'm using my own fork of the gem). I thought that content not fitting within a page should automatically overflow to the next one, but this is not the case - I'm seeing text just being cut off, sometimes in the middle of a line.

I know I can layout my pages using page-break-after:always, but this looks like dirty hard-coding, and besides the HTML comes from an ERB template so it's not always obvious where to put page breaks.

Can something be done so that page breaks are inserted automatically? Am I missing something about how this works?

Here's what the generated command line looks like

\"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\"  - - 
4

1 回答 1

15

事实证明,这是由于div用于包装文档部分的 s 上的固定大小而发生的:

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

删除widthandheight后,自动中断开始按预期工作。简单的。

于 2012-07-24T13:15:09.753 回答