Rails: WickedPDF: Page Breaks

前端 未结 6 2059
灰色年华
灰色年华 2020-12-13 12:55

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 pag

6条回答
  •  余生分开走
    2020-12-13 13:50

    I had the same problem and I discovered something that might help. This was my page break CSS code:

    .page-break {
      display: block;
      clear: both;
      page-break-after: always;
    }
    

    This didn't work because of TWO reasons:

    I. In one of the SASS imported file I had this line of code:

    html, body
      overflow-x: hidden !important
    

    II. The other problem was bootstrap

    @import "bootstrap"
    

    It looks like because of the float: left in:

    .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
      float: left;
    }
    

    the page break is no longer working. So, just add this after you import bootstrap.

    .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
      float: initial !important;
    }
    

提交回复
热议问题