title: PhantomJS cutting off content in header/footer with PDFs
body: <p>I'm using PhantomJS to dynamically generate a PDF. However it seems to always cut off some content in between the footer and header.</p>
  
  <p>Relevant files:</p>
  
  <ul>
  <li>HTML content: <a href="http://bit.ly/146Ljdp" rel="nofollow">http://bit.ly/146Ljdp</a></li>
  <li>rasterize.js file: <a href="http://bit.ly/12iSC7y" rel="nofollow">http://bit.ly/12iSC7y</a></li>
  <li>Example PDF file: <a href="http://bit.ly/10Aa309" rel="nofollow">http://bit.ly/10Aa309</a></li>
  </ul>
  
  <p>As you can see in the PDF file, the content is cut off between page 5 and 6.</p>
  
  <p>I've looked into the existing Qt and PhantomJS bugs, and am not completely sure on whether I'm not doing something right, or it's simply a bug.</p>
  
  <ul>
  <li>AFAIK the most ideal option is to use <code>page-break-inside:avoid</code>, however Qt doesn't seem to support that yet.</li>
  <li>The code content inside the PDF/document uses tables, and apparently there's been issues with that in the past: <a href="https://code.google.com/p/phantomjs/issues/detail?id=927" rel="nofollow">927</a>, <a href="https://code.google.com/p/phantomjs/issues/detail?id=989" rel="nofollow">989</a>, <a href="https://code.google.com/p/phantomjs/issues/detail?id=1038" rel="nofollow">1038</a>, <a href="https://code.google.com/p/phantomjs/issues/detail?id=880" rel="nofollow">880</a>. I tried removing all of the table elements (table, tr, td, etc) and replaced them with divs. It looked exactly the same in the browser and PDF file, but it was still being cut off.</li>
  <li>I tried a javascript hack to check each element if the top position and bottom position were on different pages, and if so, add a <code>page-break-before</code>... however I couldn't properly get the individual page size, to check the relative position from the header on each page. <code>$('element').offset().top</code> returns the position from the top of the entire document, not the current page.</li>
  </ul>
  
  <p>Any ideas on what I'm doing wrong?</p>