Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use page-break-before: always on the block that must start a new PDF page, or page-break-after: always on the block that must end the current page. Add page-break-inside: avoid only to short blocks you want kept together. These are the legacy paged-media properties wkhtmltopdf understands. Validate the result with the exact wkhtmltopdf build, Qt patch set, options and HTML used in production because its pagination engine can still split content.
The three page-break properties that wkhtmltopdf uses
CSS 2.2 defines three relevant controls for this job. WebKit lists the properties as supported, but support in a particular wkhtmltopdf package depends on its embedded WebKit and patched-Qt build. The safest approach is to keep the break target in normal block flow and test the generated PDF.
| Property | Apply it to | Result | Important limitation |
|---|---|---|---|
page-break-before: always |
The heading or block that should begin on a fresh page | Forces a page boundary immediately before that block | The block may still be split later if its contents exceed the printable page |
page-break-after: always |
The section or block that should finish the current page | Forces a boundary immediately after that block | A following block can still create additional natural breaks |
page-break-inside: avoid |
A compact callout, table, card or other block | Asks the renderer not to split the block | wkhtmltopdf documents this as only a partial remedy; it cannot keep a block taller than the printable page intact |
The CSS definitions are in the W3C CSS 2.2 Paged Media specification. The WebKit CSS feature status page documents WebKit support, but that does not guarantee identical behavior across wkhtmltopdf distributions.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchA minimal document that produces a reliable section break
Put the rule on a block-level element at the boundary. This complete example starts each chapter on a new page and asks wkhtmltopdf to keep a short note together.
#1 Best Overall
- INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
- COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
- ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
- HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Paged report</title>
<style>
@page {
size: A4;
margin: 18mm 16mm;
}
body {
font-family: Arial, sans-serif;
font-size: 11pt;
line-height: 1.45;
color: #222;
}
h1, h2, h3 {
color: #111;
}
.page-start {
page-break-before: always;
}
.page-end {
page-break-after: always;
}
.keep-together {
page-break-inside: avoid;
}
</style>
</head>
<body>
<h1>Annual report</h1>
<p>This introduction remains on the first page where space permits.</p>
<h2 class="page-start">Chapter 1</h2>
<p>Chapter 1 starts on a fresh page.</p>
<div class="keep-together">
<h3>Important note</h3>
<p>This short note should stay together when enough room remains.</p>
</div>
<section class="page-end">
<h2>Chapter 2 preparation</h2>
<p>The next section starts after an explicit boundary.</p>
</section>
<h2>Chapter 2</h2>
<p>Chapter 2 follows the forced break.</p>
</body>
</html>
Use either the “before” or “after” form for a particular boundary, not both. Applying both to adjacent elements can make an unnecessary blank page when the renderer honors each forced break.
Choosing the right boundary
Start a section on a new page
Assign page-break-before: always to the section heading or to a dedicated block immediately before the section:
.report-section {
page-break-before: always;
}
<h2 class="report-section">Financial summary</h2>
This expresses the reader-facing intent directly: the heading is the first item after the break. A heading can still be followed by a large block that naturally flows onto later pages.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →End a section at a page boundary
Use page-break-after: always when the preceding element represents a complete unit:
Rank #2
- CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
- INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
- PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
- ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
.invoice {
page-break-after: always;
}
This is useful for repeated invoices, certificates or appendices where each unit is followed by another unit. Remove the class from the final item if a trailing blank page would be undesirable.
Keep a short block together
page-break-inside: avoid is an instruction to avoid splitting, not an absolute guarantee. Apply it selectively:
.signature-box,
.callout,
.compact-table {
page-break-inside: avoid;
}
Do not put it on every ancestor in a complex document. If the element is taller than the printable area, wkhtmltopdf must split it or overflow it. The wkhtmltopdf manual associates this feature with patched Qt and describes its effect as partial.
How wkhtmltopdf actually paginates
The Debian-hosted wkhtmltopdf 0.12.6-2+b1 manual warns that “The current page breaking algorithm of WebKit leaves much to be desired.” It describes laying out content as one long page and cutting that layout into pages. Consequently, lines, images and other content can be cut even when the CSS appears reasonable.
Rank #3
- SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
- INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
- KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
- PREMIUM SUPPORT - Strong technical expertise to solve issues faster
- THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.
- A forced break controls a boundary; it does not resize content to fit the remaining space.
- An avoid rule can move a compact block to the next page, but cannot guarantee that an oversized block remains whole.
- The same stylesheet can behave differently when the embedded WebKit, Qt patch set, page size, margins or command-line flags change.
For that reason, treat the PDF—not an HTML browser preview—as the acceptance artifact.
Run wkhtmltopdf with explicit page and media settings
Pin the options used by your application so a local test matches production. For a file named report.html:
wkhtmltopdf
--page-size A4
--margin-top 18mm
--margin-right 16mm
--margin-bottom 18mm
--margin-left 16mm
report.html report.pdf
If your stylesheet contains @media print, compare output with and without --print-media-type:
Recommended Free Tools
wkhtmltopdf --print-media-type report.html report-print.pdf
wkhtmltopdf report.html report-screen.pdf
One report for wkhtmltopdf 0.12.6 with patched Qt describes images missing when print-media mode was enabled. That is a reproducible issue report, not proof that every build fails in this way; test the exact package you deploy.
Rank #4
- Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
- No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
- Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
- Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
- The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art
Layouts that commonly make a break appear ignored
Floating parents
A project issue reports page-break-before and page-break-after being ignored inside floating parent elements. The report is a diagnostic lead, not a universal rule about all floats. If a break does nothing, temporarily remove float from the target and its ancestors, render again, and then restore the layout one declaration at a time. See wkhtmltopdf issue #2371.
Nested or decorative wrappers
Place the break on the block that participates in normal flow, such as the heading or section wrapper. Moving the class from a deeply nested inline element to that outer block often makes the intended boundary unambiguous. Avoid relying on a break attached to an element whose only purpose is visual positioning.
Oversized tables, images and panels
An avoid rule cannot make a block smaller. Give images explicit dimensions or a sensible max-width, keep table content concise, and split very large panels into logical sections. If a table must remain intact, verify that its full height is less than the printable page after margins and headers are accounted for.
A practical debugging procedure
- Record the renderer. Capture the exact wkhtmltopdf version, whether Qt is patched, operating system package and every command-line option.
- Create a minimal reproduction. Keep one heading, one target block and the smallest stylesheet that still shows the failure.
- Confirm the rule reaches the PDF. Inspect the generated HTML or inline the CSS temporarily so an asset-loading or selector issue is not mistaken for pagination failure.
- Move the target into normal flow. Remove floats and unnecessary wrappers, then rerun the minimal document.
- Compare media modes. Render with and without
--print-media-type, especially if images or print-only CSS change. - Check physical dimensions. Verify page size, margins, zoom and header/footer settings; a block that no longer fits may be moved or split legitimately.
- Compare PDFs visually and by page count. Keep a known-good output beside the new output and inspect the exact boundary, images and tables.
The project’s support guidance asks for version information and a detailed reproducible case. Include the input HTML/CSS and a small output PDF when reporting a defect. The relevant print-media report is issue #5284.
Common symptoms, causes and fixes
| Symptom | Likely cause | Fix to try |
|---|---|---|
| The next heading stays on the same page | The selector misses the heading, or the target is inside a floating layout | Apply page-break-before: always directly to the heading, then test with floats removed |
| A card still splits | The card is taller than the printable page, or the renderer only partially honors avoid | Shorten or split the card; keep page-break-inside: avoid for compact blocks only |
| An unexpected blank page appears | Adjacent forced breaks or a break after the final section | Use one boundary rule and remove the final item’s page-break-after |
| Images disappear only in print mode | A build-specific interaction with --print-media-type |
Render both modes, verify the deployed version and reproduce with a minimal file before changing CSS |
| Different servers produce different pagination | Different wkhtmltopdf/Qt builds, fonts, options or page geometry | Pin the executable and fonts, log all options, and test on the production image |
Production checklist
- Use one explicit break rule at each intentional section boundary.
- Keep break targets as normal block elements wherever possible.
- Reserve
page-break-inside: avoidfor short blocks and compact tables. - Set page size and margins explicitly instead of relying on package defaults.
- Test both ordinary and print-media rendering when
@media printis present. - Test long text, missing images, slow resources and the final section, not only a short happy-path document.
- Archive the command, wkhtmltopdf version, Qt patch status, input files and representative PDF for regressions.
Or skip the browser setup
If your goal is a clean screenshot or PDF rather than maintaining a local wkhtmltopdf pipeline, ScreenshotNeo provides a one-request website screenshot API and an MCP server for AI agents. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Claude, Cursor and other MCP clients can use take_screenshot, get_page_info and capture_pdf.
For API parameters, see the ScreenshotNeo documentation. This cURL request captures a page as WebP:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The equivalent Python request is:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
And Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
Every feature is available on every plan. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots, and yearly billing gives two months free. Create a free ScreenshotNeo account.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
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.

