Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Enable html2pdf.js CSS page-break handling and tell CSS to keep each table row together:
html2pdf().set({
pagebreak: { mode: 'css' }
}).from(element).save();
tr {
break-inside: avoid;
page-break-inside: avoid;
}
If rows still split, try html2pdf.js’s selector-based option, pagebreak: { avoid: 'tr' }, then inspect the generated PDF with representative data. These settings are documented mechanisms, not an unconditional guarantee: very tall rows, particular layouts, and library or dependency versions can still produce breaks or gaps.
Use CSS mode first
html2pdf.js processes page breaks through its pagebreak option. Set mode: 'css' explicitly so CSS break rules are considered, and include both the modern and legacy declarations for browser and library compatibility.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsconst element = document.querySelector('#invoice-table');
html2pdf()
.set({
pagebreak: { mode: 'css' },
margin: [12, 12, 12, 12],
filename: 'invoice.pdf',
image: { type: 'jpeg', quality: 0.95 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
})
.from(element)
.save();
Apply the avoidance rule to rows rather than to the entire table:
#1 Best Overall
- 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
#invoice-table tr {
break-inside: avoid;
page-break-inside: avoid;
}
break-inside is the current CSS property. page-break-inside is the legacy alias that html2pdf.js examples commonly include. The project’s page-break documentation says CSS mode recognizes avoid for break-inside; its manual fixture includes a table and page-break-inside: avoid for testing. See the official page-break documentation and the manual page-break fixture.
Target rows with html2pdf.js’s avoid selector
If CSS mode does not protect the rows in your layout, use the library’s selector setting:
html2pdf()
.set({
pagebreak: {
mode: 'css',
avoid: 'tr'
}
})
.from(document.querySelector('#invoice-table'))
.save();
The avoid value accepts a CSS selector or selector list. Narrow selectors prevent unrelated content from being moved:
pagebreak: {
mode: 'css',
avoid: ['#invoice-table tr', '.keep-together']
}
You can also place controlled breaks before or after selected elements. In CSS mode, before and after recognize always, left, and right. For example:
Rank #2
- 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)
.new-section {
break-before: always;
page-break-before: always;
}
Use manual breaks for deliberate section boundaries, not as a substitute for row avoidance.
Choosing a page-break strategy
| Strategy | Best use | Trade-off |
|---|---|---|
CSS mode plus break-inside: avoid on tr |
Normal tables where only rows must remain intact | Focused and close to standard CSS, but depends on the rendered layout honoring the rule |
pagebreak.avoid: 'tr' |
Explicit row targeting when CSS alone is ineffective | Library-specific control; still verify the PDF |
avoid-all |
Diagnostic testing or documents where many blocks must stay together | Can move large amounts of content and create unexpected white space |
Explicit before/after breaks |
Known section boundaries | Manual maintenance and no solution for an oversized row |
avoid-all is a mode, for example pagebreak: { mode: ['css', 'avoid-all'] }. Start with targeted row rules; add broad avoidance only after inspecting what moved.
A complete table example
The following page contains a table with wrapped descriptions and uses both CSS declarations plus an explicit selector. Remove one mechanism at a time while diagnosing so you can see which change affects pagination.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →<section id="report">
<h1>Quarterly orders</h1>
<table id="orders">
<thead>
<tr><th>Order</th><th>Description</th><th>Total</th></tr>
</thead>
<tbody>
<tr><td>1001</td><td>Annual support and maintenance renewal</td><td>$1,200</td></tr>
<tr><td>1002</td><td>Implementation with a long description that wraps onto several lines</td><td>$3,850</td></tr>
</tbody>
</table>
</section>
<style>
#orders { width: 100%; border-collapse: collapse; }
#orders th, #orders td { border: 1px solid #bbb; padding: 6px; vertical-align: top; }
#orders tr { break-inside: avoid; page-break-inside: avoid; }
</style>
<script>
const report = document.querySelector('#report');
html2pdf().set({
pagebreak: { mode: 'css', avoid: '#orders tr' },
filename: 'orders.pdf',
jsPDF: { unit: 'mm', format: 'a4' }
}).from(report).save();
</script>
Keep the table header in a repeated header section where your HTML and rendering setup support it. Row avoidance controls whether a row is split; it does not automatically repeat a header on every PDF page.
Rank #3
- FAST DOCUMENT SCANNING — Document scanner with feeder allows you to speed through stacks with a 50-sheet Auto Document Feeder (ADF); Efficient office scanner to help you scan more productively
- INTUITIVE, HIGH-SPEED SOFTWARE — Quickly scan with this desktop document scanner; Epson ScanSmart Software lets you easily preview scans, email files, upload to the cloud, and more; Plus, automatic file naming saves even more time
- SEAMLESS INTEGRATION — Easily incorporate your data into most document management software with the included TWAIN driver; Office document scanner integrates seamlessly with business workflows
- EASY SHARING — Duplex scanner allows you to scan straight to email or popular cloud storage2 services like Dropbox, Evernote, Google Drive, and OneDrive for simple storage and sharing
- SIMPLE FILE MANAGEMENT — Scanner allows the creation of searchable PDFs with Optical Character Recognition (OCR) and convert scans to editable Word or Excel files effortlessly; Designed for home and office document scanning
Why rows can still split
The row is taller than the usable page
A row containing a large image, a long unbroken string, or many paragraphs may exceed the page’s usable height after margins, headers, and footers. It cannot fit intact without changing the content, scale, margins, or page dimensions. There is no documented universal fallback for an oversized row, so treat this as a layout constraint and check the output.
Another break mode is overriding your rule
Search for existing page-break-before, page-break-after, break-before, or break-after declarations. Remove unrelated rules while testing. A forced break around a parent can make a row appear to ignore avoid.
The table is inside a complex layout
Nested flex or grid containers, transforms, absolutely positioned content, and canvases can change the dimensions html2canvas measures. Reduce the case to one table in normal document flow, then add surrounding layout back incrementally.
The rendering stack has a defect or version interaction
html2pdf.js renders in the browser with html2canvas and jsPDF. The project README identifies those dependencies, and its issue tracker includes a report of random gaps and page-break-inside: avoid not being honored. Review the reported issue and the project README when behavior differs between versions.
Rank #4
- Scanner type: Document
- Connectivity technology: USB
- With Auto Scan Mode, the scanner automatically detects what you're scanning
- Digitize documents and images
A reliable troubleshooting sequence
- Confirm the target. Make sure the selector points to the rows in the element passed to
.from(), not to a different copy of the table. - Use a minimal reproduction. Export one table with short rows, wrapped rows, and a row near the bottom margin.
- Enable CSS mode only. Start with
pagebreak: { mode: 'css' }and the two row declarations. - Try the selector option. Change to
avoid: 'tr'or a specific table selector. Do not addavoid-allyet. - Inspect computed layout. In browser developer tools, check row height, margins, overflow, transforms, and active break rules.
- Test boundary cases. Include long wrapped text, images, rows close to the page bottom, and an exceptionally tall row.
- Check versions and dependencies. Reproduce with the exact html2pdf.js, html2canvas, and jsPDF versions used in production.
- Compare the PDF, not just the preview. Open the saved file and verify every page boundary; a browser preview of the source HTML is not evidence that pagination succeeded.
Performance, reliability, and output quality
html2pdf.js is client-side. html2canvas first rasterizes the DOM and jsPDF writes the PDF, so large tables and high html2canvas.scale values consume more memory and take longer. Use a scale appropriate for the required text and image sharpness, and avoid exporting hidden duplicate tables. Wait until fonts, images, and asynchronous data are ready before calling .from(); otherwise measured row heights can change after pagination.
For repeatable output, fix the paper format, orientation, margins, viewport, and font loading. Keep content inside the printable width so wrapping is stable. If a row contains remote images, make sure they load without cross-origin restrictions that would leave blank canvases. Generate PDFs in the same browser environment used for testing because client-side rendering can vary with fonts and viewport dimensions.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
For server-side or automated captures, ScreenshotNeo returns a screenshot or PDF from one request. Its capture pipeline accepts cookie and consent banners, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn each cleanup step off. Only clean shots are billed; bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
Use the ScreenshotNeo API documentation for authentication and options. A PDF request can target the URL that renders your table:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
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}`);
ScreenshotNeo also supports full-page capture with lazy images loaded, CSS-element capture, custom CSS and JavaScript, waits for a selector, delay, or network idle, custom headers and cookies, device and viewport settings, PDF paper size, margins, landscape mode and page ranges, caching with a chosen TTL, signed links, asynchronous jobs, webhooks, bulk capture of up to 100 URLs per call, and a usage API. Plans include 1,000 free shots per month with no card; paid plans start at $5 for 3,000 shots. Start with the free ScreenshotNeo account.
Best Value
- OUR MOST ADVANCED SCANSNAP. Large touchscreen, fast 45ppm double-sided scanning, 100-sheet document feeder, Wi-Fi and USB connectivity, automatic optimizations, and support for cloud services. Upgraded replacement for the discontinued iX1600
- CUSTOMIZABLE. SHARABLE. Select personalized profiles from the touchscreen. Send to PC, Mac, mobile devices, and clouds. QUICK MENU lets you quickly scan-drag-drop to your favorite computer apps
- STABLE WIRELESS OR USB CONNECTION. Built-in Wi-Fi 6 for the fastest and most secure scanning. Connect to smart devices or cloud services without a computer. USB-C connection also available
- PHOTO AND DOCUMENT ORGANIZATION MADE EFFORTLESS. Easily manage, edit, and use scanned data from documents, receipts, photos, and business cards. Automatically optimize, name, and sort files
- AVOIDS PAPER JAMS AND DAMAGE. Features a brake roller system to feed paper smoothly, a multi-feed sensor that detects pages stuck together, and skew detection to prevent paper damage and data loss
Frequently Asked Questions
Does page-break-inside: avoid guarantee an unbroken row?
No. html2pdf.js documents support for the rule in CSS mode, but layout constraints, oversized rows, and version-specific behavior can still defeat it. Always inspect the generated PDF.
Should I apply avoid to the whole table?
Usually no. Target tr or a table-specific row selector so the library can paginate between rows instead of moving the entire table.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →What if a row is taller than one PDF page?
It cannot remain intact at the current scale, margins, and paper size. Shorten or restructure the content, reduce scale, adjust margins or page dimensions, or accept a split.
Why do I see blank gaps after enabling avoidance?
Avoidance can move a row or block to the next page when it no longer fits. Broad avoid-all, forced breaks, and complex parent layouts can amplify the gap; test targeted selectors first.
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.

