[SalesForce] Visualforce: How to render multiple records, 1/page in a single PDF

I would like to render PDF page base on the amount of record I retrieve using SOQL.

example If I have 10 invoice forms, I should be able to render 10 pages in 1 PDF.

Best Answer

This is possible with having some extra css.
Wrap your invoice data with a div and introduce css class as below

.page-break {
.page-break:first-child {
         page-break-before: avoid;

@page {
        size: A4;
        @bottom-center {
            content: "Page " counter(page) " of " counter(pages);

<apex:repeat value="{!yourList}" var="item">
  <div class="page-break" >
    <!-- Your content -->

page-break css class help you to start every new child of your list in a new page. And in above .page-break:first-child is for avoiding generating empty first page. @page is an additional but thought to add it since in this kind of scenario it's valuable. It's giving you in which page are you out of how many pages.