New: PDF to E-Invoice for Factur-X/ZUGFeRD, and PDF to PDF/A for archive-ready PDF/A-3b.

HTML-to-PDF Page Breaks: Start New Pages and Keep Sections Together

8 Minutes Read

Control where new pages begin when converting HTML to PDF with PDF.co and Zapier. This example creates a two-page document, then shows how to keep short sections together and avoid common layout problems.

Step 1: Configure HTML to PDF in Zapier

Open your Zap and add PDF.co → HTML to PDF after its trigger.

Connect your PDF.co account through the sign-in window and approve Zapier’s access.

Configure:

  • HTML or URL Input: Paste the HTML from Step 2.
  • HTML Template ID: Leave blank.
  • Page Size: A4.
  • Page Orientation: Portrait.
  • Custom Margins: 20mm.
  • Media Type: Print.
  • Name: page-break-example.pdf.

See the HTML to PDF action reference for additional settings.

Step 2: Add the HTML and Page-Break Rules

Paste this complete example into HTML or URL Input:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Page-break example</title>
  <style>
    body {
      font: 12pt Arial, sans-serif;
      color: #222;
    }

    @media print {
      .new-page {
        page-break-before: always;
        break-before: page;
      }

      .keep-together {
        page-break-inside: avoid;
        break-inside: avoid;
      }
    }
  </style>
</head>
<body>
  <section>
    <h1>Project summary</h1>
    <p>This section appears on the first page.</p>
  </section>

  <section class="new-page">
    <h1>Review and approval</h1>
    <p>This section starts on a new page.</p>

    <div class="keep-together">
      <h2>Approval details</h2>
      <p>Reviewer: Example Reviewer</p>
      <p>Decision: Awaiting review</p>
    </div>
  </section>
</body>
</html>

Start a Section on a New Page

Apply class="new-page" to the section that must begin next. Its CSS forces a page break before that section.

Place the class on the content itself rather than adding an empty paragraph as a page separator.

Keep a Short Section Together

The keep-together class asks the renderer to avoid splitting the approval block between pages:

.keep-together {
  page-break-inside: avoid;
  break-inside: avoid;
}

Use this for short blocks such as approval details or a compact summary. A block taller than the printable page area cannot fit on one page, so do not apply it to an entire long report. See the CSS fragmentation specification.

Avoid a Blank Final Page

Do not force another page after the final content. If an unwanted blank page appears, check for:

  • page-break-after: always on the final element.
  • break-after: page on the final element.
  • A trailing empty element carrying the new-page class.

Prevent Clipped Content

Let long containers grow naturally instead of assigning them a fixed page-height value. Check for overflow: hidden if content disappears rather than continuing onto another page.

Keep Page Size, Page Orientation, and Custom Margins consistent when comparing outputs. Changing the paper size or margins changes the space available for content.

Use Media Type → Print so the example’s print-specific CSS applies. The browser’s normal screen view is not a substitute for checking the generated PDF.

Step 3: Test and Save the PDF

Test the PDF.co action and open the returned PDF URL.

First, confirm that the short example produces two pages, with Review and approval beginning on the second page.

Then add enough text before the approval block to push it near a page boundary. Check that:

  • The short approval block stays together where it can fit.
  • Longer content continues onto additional pages.
  • No content is clipped.
  • There is no unwanted blank final page.

Repeat the test with Letter paper size if your recipients use it.

To retain the output, add Google Drive → Upload File:

  • Folder: Select the destination folder.
  • File: Map the PDF.co output URL.
  • File Name: Enter page-break-example.
  • File Extension: Enter pdf.
  • Convert to Document?: Select No.

Test the upload and open the saved PDF. PDF.co’s download URL is temporary, so save the file during the workflow.

Related Tutorials

See Related Tutorials