I am using Grover to convert HTML pages to PDF, which leverages Puppeteer for Google Chrome. I have a bunch of Ruby on Rails partials that I am cycling through and rendering, and I am inserting a page break between each partial render. However, I noticed that my page break is a p element, and sometimes if the text on the page extends all the way to the bottom of the page by the footer, then the p element ends up being on the next page, followed by the page break. This causes a blank page.
Here's what I'm using as a page break:
<p style="page-break-after: always;"> </p>
I think this is what's happening:
If I adjust the footer margins to be smaller, then it works fine (because the p element has more room on the existing page), but I constantly have to tweak this footer margin.
This is what my Rails code looks like:
<% items.each do |item| %>
<% unless item == items[0] %>
<p style="page-break-after: always;"> </p>
<% end %>
<%= render partial: "common/report_templates/shared/item" %>
<% end %>
