title: Better Page Breaks in Wicked_PDF for Rails
body: <p>I was able to use the technique described <a href="https://stackoverflow.com/questions/5806943/rails-wickedpdf-page-breaks">here</a> to get page breaks at certain points I wanted. However, I have a two column layout as follows:</p>
  
  <pre><code>    &lt;div class='book-main-image'&gt;&lt;img src="&lt;%= page[:image] %&gt;" /&gt;&lt;/div&gt;
  
      &lt;div class='book-headline-holder'&gt;
        &lt;h1&gt;&lt;%= page[:title] %&gt;&lt;/h1&gt;
      &lt;/div&gt;
  
      &lt;div class='book-sidebar book-main-section'&gt;
        &lt;div class='book-sidebar-section'&gt;
          &lt;h4&gt;Location&lt;/h4&gt;
          &lt;div class='sidebar-text'&gt;&lt;%= page[:location] %&gt;&lt;/div&gt;
  
          &lt;h4&gt;Client&lt;/h4&gt;
          &lt;div class='sidebar-text'&gt;&lt;%= page[:client] %&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class='book-main-content book-main-section'&gt;
        &lt;div class='book-body'&gt;&lt;%= page[:body].html_safe %&gt;&lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Which is styled like this:</p>
  
  <pre><code>  .book-main-section    { display: inline-block; vertical-align: top; }
    .book-sidebar         { width: 20%; margin-left: 3%; margin-top: 10px; }
    .book-main-content    { width: 70%; margin-left: 2%; }
  </code></pre>
  
  <p>This is fine most of the time, but if the <code>book-body</code> div + the height of <code>book-main-image</code> and <code>book-headline-holder</code> are longer than one page, both <code>book-main-section</code> divs are shifted to the next page, leaving an image and headline on one page with a huge gap and the rest of the content on the next page. </p>
  
  <p>I tried to start introducing some javascript (using an external link to jQuery in the page) to break up the page content into separate divs based on the height of them, but I could never get the Javascript to execute (seems to totally ignore it). Is there any other way to avoid this, or to get the javascript working? </p>