October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
CSS

How to Split Long HTML Content Across PDF Pages

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Long HTML should normally flow across PDF pages; the reliable solution is to treat pagination as a paged-media fragmentation problem rather than trying to shrink every component onto one sheet. Add print-only CSS, define the page with @page, use modern break-* properties to guide boundaries, and apply break-inside: avoid only to short groups that can actually fit. Let paragraphs, lists and other oversized content split naturally, then verify the result in the exact PDF renderer and version you deploy.

What PDF pagination is actually doing

A browser lays out a continuous document. PDF output divides that flow into page boxes with fixed dimensions and margins. CSS can request a break before or after an element, or discourage a break inside it, but it cannot make content taller than a page fit intact. If a container begins at the top of a page and is longer than the printable area, a conforming printer may print its first portion and continue it on the next page. Designing for continuation prevents clipped text and missing content.

Keep screen and print layouts separate. A responsive card grid that looks right in a browser may be inappropriate on paper, so place PDF-specific rules in @media print and test generated files rather than relying on the screen preview.

Start with a print stylesheet and page geometry

/* screen styles remain unchanged */
@media print {
  body {
    margin: 0;
    color: #111;
    background: #fff;
    font: 11pt/1.45 Arial, sans-serif;
  }

  @page {
    size: A4 portrait;
    margin: 18mm 16mm 20mm;
  }

  .no-print { display: none !important; }
  a { color: inherit; text-decoration: none; }
}

Use a named size such as A4 or Letter, and specify orientation when it matters. The margins in @page define the printable region; they are not the same as a component’s internal padding. If your renderer also accepts a format, width, height or margin option, decide which setting is authoritative. Puppeteer’s preferCSSPageSize option gives the CSS @page size priority over those PDF options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
  • Scanner type: Document
  • Connectivity technology: USB
  • With Auto Scan Mode, the scanner automatically detects what you're scanning
  • Digitize documents and images

Control where fragments may split

Force a major-section break

.chapter { break-before: page; }
.appendix { break-before: page; }

Use a forced break for chapters, invoices or appendices that must start on a new sheet. Avoid forcing breaks on every heading: excessive blank space is usually worse than a natural split.

End a section cleanly

.end-section { break-after: page; }

This is useful when a section is a complete page unit, but should be reserved for deliberate boundaries.

Keep small units together

figure,
.callout,
.card,
table.summary {
  break-inside: avoid;
}

h1, h2, h3 {
  break-after: avoid;
}

An image with its caption, a short warning box or a compact summary table often should remain together. “Avoid” is a preference, not a promise. If the unit cannot fit in the remaining space, the renderer must split it or move part of it; CSS cannot override the physical page.

Allow long content to continue

.article-body,
.long-list,
pre,
.long-table {
  break-inside: auto;
}

Do not put break-inside: avoid on an article wrapper, a long list or a large table. Doing so can create large blank areas, unexpected overflow or a split that the engine handles differently than expected. A very long paragraph, code block or table needs a continuation strategy, not forced containment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep headings, widows and orphans under control

A heading at the bottom of a page with no following text is hard to read. break-after: avoid on headings asks the renderer to keep the next content nearby. Where supported, widows and orphans specify the minimum number of text lines left at the top or bottom of a page:

Rank #2
Sale
Brother DS-640 Compact Mobile Document Scanner, (Model: DS640)
  • FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
  • READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
  • WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
  • OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)
@media print {
  p, li { widows: 3; orphans: 3; }
  h2, h3 { break-after: avoid; }
}

Support differs by engine and release, so treat these as tested preferences rather than universal guarantees. Legacy aliases such as page-break-before, page-break-after and page-break-inside remain useful for older implementations, but write modern break-* properties first.

Patterns for common HTML components

Images and figures

figure { margin: 0 0 1rem; break-inside: avoid; }
img { max-width: 100%; height: auto; }

Ensure the intrinsic image dimensions cannot exceed the printable width. If an image is taller than one page, allow it to split or resize it intentionally; “keep together” cannot preserve an oversized figure.

Tables

table { width: 100%; border-collapse: collapse; }
thead { display: table-header-group; }
tr { break-inside: avoid; }

Repeating a table header is renderer-dependent. Avoiding a row split is useful for short rows, but a very tall cell may still fragment. For wide tables, choose landscape pages or simplify columns instead of relying on overflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Lists and cards

Let a long list flow. Apply break-inside: avoid to an individual short card, not to the list container. If a card contains a variable-length description, define a maximum design size or accept continuation.

Code blocks

Code may be wider or taller than a page. Use wrapping where readability permits, reduce print-only font size modestly, and allow a long block to continue. Never hide overflow merely to make a screenshot look tidy; hidden lines are lost output.

Rank #3
Plustek PS186 Desktop Document Scanner, with 50-Pages Auto Document Feeder (ADF). for Windows 7/8 / 10/11 (Intel/AMD only)
  • Up to 255 customize favorite scan file setting with "Single Touch" , Support Windows 7/8/10
  • Turn paper documents into searchable, editable files - save scans as searchable PDF files; OCR function included
  • Info Barcode function - automatic categorization of complicate documentation and data with 1D or 2D Barcode page.
  • Intelligent color and image adjustments — Auto Rotate, Crop, Deskew and blank page remove with Plustek Image Processing Technology
  • Easy send scanned files to FTP server or personal NAS (FTP) with PDFs , Jpeg , TIFF or Png format. User can download scanner driver from Plustek website

Generating PDFs with Puppeteer

Puppeteer’s Page.pdf() renders with print CSS media. A complete Node.js example:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({headless: 'new'});
try {
  const page = await browser.newPage();
  await page.goto('https://example.com/report', {waitUntil: 'networkidle0'});
  await page.emulateMediaType('print');
  await page.pdf({
    path: 'report.pdf',
    printBackground: true,
    preferCSSPageSize: true,
    displayHeaderFooter: false
  });
} finally {
  await browser.close();
}

Wait for the content your page actually needs. networkidle0 is not a guarantee that a client-side chart has finished rendering; wait for a specific selector or application-ready flag when necessary. If you set format or explicit dimensions while also using @page, verify which choice wins in your installed Puppeteer version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Using a dedicated paged-media renderer

WeasyPrint is designed around HTML/CSS paged media and documents support for page fragmentation, @page, margin boxes and widow/orphan controls. It can be a good fit for document-style HTML that does not require a full browser’s JavaScript behavior. Puppeteer is generally the more natural fit for pages whose data and layout are produced by browser JavaScript. Neither choice is universally better: compare the CSS features you need, JavaScript requirements, headers and footers, page sizing, deployment constraints and the exact installed release. Published feature documentation does not establish a universal speed, fidelity or cost winner.

Debugging page-break failures

Everything appears on one giant page

Check that PDF generation is enabled, print CSS is being applied, and the renderer is not using a screenshot or fixed-height canvas path. In Puppeteer, call page.pdf() and use print media.

Sections start on unexpected blank pages

Look for multiple forced breaks, large top margins, or break-inside: avoid on a parent that cannot fit. Remove the parent-level avoid rule and keep it on the small component that needs protection.

Rank #4
Hczrc Portable Scanner, Photo Scanner for A4 Documents, Handheld Scanner for Business, Photo, Picture, Receipts, Books, JPG/PDF Format Selection, UP to 900 DPI, with 16G SD Car
  • Note: No software installation is required. You need 2 AA batteries ( not included) and a memory card ( included) to use it directly. Scan mode: Press and hold "Scan" for 2 seconds to turn on the device, and then press "Scan", the green light is on. The scanner moves to scan the file until the green light turns off automatically (or press the "Scan" key and the green light goes out). The number shown on the display increases by 1 to indicate that the scan is complete.
  • Portable Scanner scans images or pictures quickly: Store JPEG/PDF files within seconds, scan images or pictures quickly, plug and play, no need any software preinstalled. Compatible with Windows XP/7/Vista/Mac OS 10.4 or above version.
  • Lightweight and travel-friendly: Stored in Micro SD card directly, support read data on your computer or phone with USB connected. Powered by 2pcs AA batteries, Compact Design, it is convenient to carry outside.
  • 3 Image Resolution: 3 modes of resolution for your options: 300dpi/600dpi/900dpi, you can save it at the clearest way, picture and document are showed clear as it is. Freely choose your favorite resolution.File Format: JPEG/PDF format is all available, Great storage capacity as it supports 32G Micro SD card(Included 16GB Card),total meet your need for business trip or daily use.
  • Widely Used: It is applicable in bank, insurance business, real estate agency,home, office, library or outdoors. suitable for lawyer, businessmen, students, travelers and amateur archivists. Scan your important files and save them immediately, no struggling in finding a printing shop, keep it confidential.

Text or images are clipped

Search for overflow: hidden, fixed heights and absolute positioning. Remove those print overrides, constrain images to the printable width, and allow oversized blocks to fragment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CSS page size is ignored

Confirm the renderer option that controls precedence. In Puppeteer, set preferCSSPageSize: true when CSS should control the paper size, and avoid contradictory format and width/height settings.

Fonts or late content are missing

Wait for fonts and data before calling the PDF method. Use an application-ready selector, and verify that authenticated assets, cross-origin images and cookies are available in the rendering context.

Different engines produce different breaks

That is expected. Fragmentation and paged-media support evolves by engine and version. Pin the renderer, keep a small set of representative documents as regression fixtures, and inspect output after upgrades.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability and operational checks

  • Reuse a browser process for batches, but create an isolated page per document and close pages promptly.
  • Set navigation and rendering timeouts; record the URL, renderer version and options with each job.
  • Prefer deterministic data and fonts for repeatable pagination. Network-loaded ads, animations and personalized content can move boundaries.
  • Test short, exactly-full, and multi-page content, plus oversized figures, long tables, missing images and right-to-left or non-Latin text if your product supports them.
  • Compare PDFs visually and extract text in automated checks so a clipped or missing continuation is caught.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. For a one-call capture, use the API documented at https://screenshotneo.com/docs/:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Epson Workforce ES-50 Compact & Lightweight Mobile Document Scanner
  • PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
  • QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
  • VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
  • INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
  • EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. It is a screenshot and capture service, so use your HTML-to-PDF renderer when you need precise multi-page document pagination.

Create a free ScreenshotNeo account to start with 1,000 screenshots a month and no card.

Checklist before shipping

  • Define @page size and margins.
  • Put print-only rules in @media print.
  • Use forced breaks only for true section boundaries.
  • Keep short figures and cards together; let long content flow.
  • Keep headings with following content where supported.
  • Set renderer options deliberately, especially CSS page-size precedence.
  • Test the exact engine and version used in production.
  • Inspect for clipping, missing assets, blank pages and unwanted overflow.

Frequently Asked Questions

Can CSS guarantee that a component never splits?

No. Break-avoidance is advisory, and an element taller than the page must be fragmented or otherwise handled by the renderer.

Should I use page-break-inside or break-inside?

Use modern break-inside, break-before and break-after properties, retaining legacy page-break aliases when compatibility with older engines is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does my PDF differ between Puppeteer and WeasyPrint?

They implement different layout engines and feature sets. Pin versions and validate the exact renderer used for production.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.