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

To capture content hidden inside a fixed-height, scrollable <div>, pass that element’s scrollWidth and scrollHeight as html2canvas’s windowWidth and windowHeight. Then send the resulting canvas to a PDF library such as html2pdf.js. This renders the element’s full DOM extent instead of only the portion currently visible in the browser.

The method is not a native browser screenshot. html2canvas reconstructs an image from DOM and computed-style information, so validate the PDF for clipping, unsupported CSS, remote images, cross-origin frames, and browser canvas limits.

Capture the complete scrollable element

Give the scrollable element an identifier, load html2canvas, and use its measured content dimensions:

<div id="content-to-export" class="scroll-box">
  <!-- Long content, including material below the current scroll position -->
</div>

<script src="https://cdn.jsdelivr.net/npm/html2canvas@latest/dist/html2canvas.min.js"></script>
<script>
  async function captureScrollableDiv() {
    const element = document.querySelector('#content-to-export');
    if (!element) throw new Error('Scrollable element was not found');

    const canvas = await html2canvas(element, {
      windowWidth: element.scrollWidth,
      windowHeight: element.scrollHeight,
      useCORS: true
    });

    return canvas;
  }
</script>

scrollWidth and scrollHeight describe the element’s complete content extent, including the portion hidden by overflow: auto or overflow: scroll. The returned canvas can be displayed, downloaded, or passed to a PDF generator.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
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

Download a PNG while testing

const canvas = await captureScrollableDiv();
const link = document.createElement('a');
link.download = 'scrollable-content.png';
link.href = canvas.toDataURL('image/png');
link.click();

Inspect this image before adding PDF conversion. If the PNG is already clipped or blank, changing PDF settings will not repair the capture.

Convert the canvas to a PDF

html2pdf.js is a browser-side option that combines html2canvas with jsPDF. Its page-break and page-size controls are useful when a tall canvas must become a multi-page document.

<script src="https://cdn.jsdelivr.net/npm/html2pdf.js@latest/dist/html2pdf.bundle.min.js"></script>
<script>
  async function exportScrollableDivAsPdf() {
    const element = document.querySelector('#content-to-export');
    if (!element) throw new Error('Scrollable element was not found');

    const canvas = await html2canvas(element, {
      windowWidth: element.scrollWidth,
      windowHeight: element.scrollHeight,
      useCORS: true
    });

    await html2pdf()
      .set({
        margin: 10,
        filename: 'scrollable-content.pdf',
        image: { type: 'jpeg', quality: 0.95 },
        html2canvas: { scale: 1 },
        jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
        pagebreak: { mode: ['css', 'legacy'] }
      })
      .from(canvas)
      .save();
  }
</script>

Some html2pdf.js versions accept an element directly through .from(element), but passing the already-rendered canvas makes it explicit that the scroll-dimension capture is being used. Test page breaks with your installed version; a single very tall image can still be scaled or split in an undesirable way.

Understand the two sets of dimensions

The most common configuration mistake is confusing html2canvas’s window dimensions with its canvas dimensions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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)
Option Meaning Value for a scrollable div
windowWidth The virtual browser-window width used while rendering. It can change responsive media-query results. element.scrollWidth
windowHeight The virtual browser-window height used while rendering. element.scrollHeight
width The canvas width, when you explicitly override it. Usually leave unset unless you have a measured layout requirement.
height The canvas height, when you explicitly override it. Usually leave unset; forcing a height can create clipping or excess blank space.

Setting the window dimensions does not automatically remove every CSS constraint in the cloned document. If the clone still has a fixed height, hidden overflow, or a component that only renders rows currently in view, inspect the cloned layout and adjust the page-specific styles before capture.

Prepare the page before rendering

Wait for asynchronous content

Capture only after your application has inserted all rows, expanded lazy sections, and finished loading images. There is no universal delay that works for every site. Prefer an application state signal, such as a promise that resolves after data and images are ready.

async function waitForImages(root) {
  const images = [...root.querySelectorAll('img')];
  await Promise.all(images.map(img => {
    if (img.complete) return Promise.resolve();
    return new Promise(resolve => {
      img.addEventListener('load', resolve, { once: true });
      img.addEventListener('error', resolve, { once: true });
    });
  }));
}

const element = document.querySelector('#content-to-export');
await waitForImages(element);
const canvas = await html2canvas(element, {
  windowWidth: element.scrollWidth,
  windowHeight: element.scrollHeight,
  useCORS: true
});

For virtualized lists, scrolling the container may be necessary to make the application render additional rows, or you may need an export-specific view that renders the complete dataset. html2canvas cannot capture DOM nodes that your application never created.

Preserve a stable layout

  • Freeze animations and transitions during export so elements do not move between layout and paint.
  • Use a dedicated print/export class to remove sticky toolbars, hover menus, and controls that should not appear in the PDF.
  • Measure dimensions after fonts and images have loaded; late font substitution can change line wrapping and height.
  • Keep the element’s background, padding, and color styles explicit rather than relying on browser defaults.

What html2canvas can and cannot reproduce

The project documentation describes the result as a DOM-based reconstruction rather than a guaranteed pixel-identical browser screenshot. CSS properties that html2canvas does not implement, complex filters, unusual blend modes, and browser-native controls may differ from what you see on screen. Check the supported-features documentation for the version you ship and compare output in the browsers your users actually run.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Epson Workforce ES-400 II High-Speed Color Duplex Desktop Document Scanner
  • 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

Remote images

Same-origin images are the straightforward case. For a cross-origin image, useCORS: true asks the browser to load it with CORS, but the image server must send an appropriate Access-Control-Allow-Origin response. This option cannot bypass browser security. If the remote server does not permit your origin, host the asset on an allowed origin or use a server-side proxy that you control.

Frames

Same-origin iframe contents can be traversed recursively according to the project documentation. Cross-origin frames cannot be read by page JavaScript, so their contents will not be available to html2canvas.

Searchable text and accessibility

A canvas-to-PDF pipeline is fundamentally image-oriented. Text may be rasterized rather than selectable, searchable, or exposed as semantic document structure. For invoices, reports, accessibility workflows, or machine processing, generate a semantic HTML/print document or a PDF directly from structured data instead of relying on a canvas image.

Canvas limits and very tall content

Browser limits vary by engine, platform, graphics hardware, and updates. The html2canvas FAQ gives rough current guides of approximately 32,767 pixels for one canvas dimension in evergreen Chrome/Chromium, Firefox, and desktop Safari; approximately 268 million pixels of total canvas area for Chrome/Chromium; and approximately 472 million pixels for Firefox. These are not guarantees.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
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

A scrollable element that is 20,000 pixels high and 2,000 pixels wide already requires about 40 million pixels before any device-pixel scaling. A larger scale multiplies memory and pixel count. If the output is blank, truncated, or the tab becomes unresponsive, log the measured dimensions and reduce the capture size.

Split oversized content into sections

When one canvas is impractical, capture logical sections separately and add each image to successive PDF pages. This is an engineering workaround rather than a universal html2canvas algorithm:

const sections = [...document.querySelectorAll('.export-section')];
const pdfImages = [];

for (const section of sections) {
  const canvas = await html2canvas(section, {
    windowWidth: section.scrollWidth,
    windowHeight: section.scrollHeight,
    useCORS: true,
    scale: 1
  });
  pdfImages.push(canvas.toDataURL('image/png'));
}

// Add each data URL to your PDF library on its own page,
// choosing page dimensions and margins for your document.

Choose boundaries that do not cut through tables or cards, and inspect the final multi-page PDF for repeated headers, margins, and readable text.

Troubleshooting checklist

Symptom Likely cause Fix
Only the visible portion is captured The renderer used the viewport dimensions or the element was measured before expansion. Pass scrollWidth and scrollHeight as windowWidth and windowHeight after content is fully rendered.
Canvas is blank or stops halfway The requested canvas exceeds a browser or platform limit. Record width, height, and area; lower scale, reduce the export width, or capture sections separately.
Images are missing Cross-origin responses do not grant access, or images were not loaded yet. Wait for images, use useCORS: true, verify response CORS headers, or proxy the assets.
Styles differ from the page html2canvas does not implement every CSS feature, or responsive rules changed under the virtual window. Check supported features, set deliberate window dimensions, and add export-specific CSS.
An iframe is empty The iframe is cross-origin. Use a same-origin frame, export its data separately, or obtain the content through an authorized server-side process.
Rows are missing from a long list The list is virtualized and off-screen rows are not present in the DOM. Render all rows in an export view or use an application-level data export.
PDF text cannot be selected The canvas was embedded as an image. Generate a semantic or print-oriented PDF when selectable text and accessibility are requirements.
PDF pages have awkward breaks A single tall image is being scaled or split by the PDF library. Use page-break and page-size controls, or capture smaller sections and place them deliberately.

Performance and reliability practices

  • Capture at the smallest CSS width that preserves the required layout; unnecessary width increases pixel count.
  • Use a moderate scale for ordinary documents. Retina-scale output can improve sharpness but rapidly increases memory use.
  • Release large canvases after saving, and avoid retaining multiple full-size data URLs in memory.
  • Run export from a user action and show progress for long documents; a browser tab can be killed if memory pressure becomes high.
  • Test Chrome/Chromium, Firefox, and Safari separately when the document is business-critical because limits and CSS rendering differ.
  • Open the produced PDF and check the beginning, middle, and end, not just whether a download occurred.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. It is the first option to try when you want a service rather than maintaining browser capture code: it removes cookie banners, newsletter popups, and chat widgets before capture, and only clean shots are billed.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

For a URL that is publicly reachable, call the API directly:

Best Value
Sale
ScanSnap iX2500 Wireless or USB High-Speed Document Scanner, Black
  • 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
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}`);

See the ScreenshotNeo API documentation for request options. The service supports full-page capture with lazy images loaded, CSS-selector element capture, custom CSS and JavaScript, waits for selectors, delays or network idle, PDF output with paper size and margins, device and viewport settings, cookies and headers, and bulk capture of up to 100 URLs per call. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing result. ScreenshotNeo has a free allowance of 1,000 screenshots per month without a card. Paid plans start at $5 for 3,000 shots, with every feature available on every plan. Create a free ScreenshotNeo account.

When to choose each approach

Requirement html2canvas in your page ScreenshotNeo or another service
Capture a private, authenticated DOM already open in the user’s browser Good fit; no server access is needed. Requires a way to authenticate the requested URL, such as supported headers or cookies.
Exact control over application state and export-only styles Best fit because your code controls the DOM. Use service-side CSS/JavaScript options when the page is publicly reachable.
Searchable, semantic PDF Not a natural fit when the output is a canvas image. Use a document-generation workflow designed for text and accessibility.
Repeatable capture without shipping browser code Requires maintaining client-side integration and handling browser limits. An API or MCP server can centralize capture and report billing/page verdicts.

FAQ

Frequently Asked Questions

Can html2canvas capture content inside a nested scrollable div?

Yes, if the nested content exists in the DOM. Select the specific container and pass that container’s own scrollWidth and scrollHeight. If a child list is virtualized, off-screen rows must first be rendered.

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

Should I set html2canvas width and height too?

Usually no. The scroll-dimension fix uses windowWidth and windowHeight. Explicit width or height values are separate canvas controls and can introduce clipping or blank space unless you have a measured reason to override them.

Does useCORS download images from any domain?

No. It works only when the image server permits your origin with suitable CORS headers. Browser same-origin policy still applies.

Why is my PDF huge?

A tall raster canvas contains many pixels, and PNG or high-quality JPEG data can consume substantial memory. Lower the capture scale, split sections, or generate a text-oriented PDF when image fidelity is not essential.

Quick Recap

Bestseller No. 4
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
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
$75.00

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.

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