Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To capture content beyond the visible viewport, render the element at its full scroll dimensions:
const element = document.querySelector('#capture');
const canvas = await html2canvas(element, {
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
});
For a page, use document.body or a container that actually contains the complete document. This changes the virtual rendering window; it does not turn html2canvas into a pixel-perfect browser screenshot. Scrollable child elements, fixed positioning, cross-origin assets, unsupported CSS and browser canvas limits need separate handling.
What “beyond the viewport” means in html2canvas
html2canvas rebuilds a canvas from the DOM, computed styles and browser-readable assets. It normally uses the current rendering window, so a tall element can be clipped at the viewport even when its scrollHeight is much larger. The official FAQ’s core fix is to set windowWidth and windowHeight to the target’s scroll dimensions.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated 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 matchThose options also affect media-query evaluation. A wider or taller virtual window can select different responsive CSS than the user currently sees. Treat the resulting image as a DOM reconstruction, not a native compositor capture: unsupported CSS, fonts, filters, videos and complex browser effects may differ from the live page.
#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
Capture an entire page
Basic full-page capture
import html2canvas from 'html2canvas';
async function capturePage() {
const target = document.body;
const canvas = await html2canvas(target, {
windowWidth: Math.max(
document.documentElement.scrollWidth,
document.body.scrollWidth
),
windowHeight: Math.max(
document.documentElement.scrollHeight,
document.body.scrollHeight
),
scrollX: 0,
scrollY: 0,
backgroundColor: '#ffffff'
});
const link = document.createElement('a');
link.download = 'full-page.png';
link.href = canvas.toDataURL('image/png');
link.click();
}
capturePage().catch(console.error);
Using the larger of the document and body dimensions avoids choosing a body height that excludes content positioned outside it. If your application has a page shell, capturing that shell is often more predictable than capturing body:
const target = document.querySelector('#page-shell');
const canvas = await html2canvas(target, {
windowWidth: target.scrollWidth,
windowHeight: target.scrollHeight,
scrollX: 0,
scrollY: 0
});
Control cropping and resolution
Use x, y, width and height when you intentionally want a region rather than every pixel of the target. scale multiplies output pixels and is useful for high-DPI images, but it also multiplies memory use and canvas-limit risk.
const canvas = await html2canvas(target, {
windowWidth: target.scrollWidth,
windowHeight: target.scrollHeight,
x: 0,
y: 0,
width: target.scrollWidth,
height: target.scrollHeight,
scale: Math.min(window.devicePixelRatio, 2)
});
Do not assume that windowWidth and windowHeight alone neutralize fixed or sticky headers. Set scrollX and scrollY deliberately when the target’s layout depends on page scroll position. Test at the same scroll position and viewport width used by your users.
Recommended Free Tools
Capture a scrollable div
Why document settings do not reveal a child’s hidden content
A page that scrolls and a child such as .scroll-panel with overflow: auto are different problems. The document can be full height while the child remains constrained to a small box. Giving html2canvas document-sized window dimensions does not automatically expand that independent scroll area.
Expand the cloned element with onclone
The onclone callback lets you modify the cloned document used for rendering without changing the live page. Expand the child in that clone:
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)
const panel = document.querySelector('.scroll-panel');
const canvas = await html2canvas(panel, {
windowWidth: panel.scrollWidth,
windowHeight: panel.scrollHeight,
onclone: clonedDocument => {
const clone = clonedDocument.querySelector('.scroll-panel');
clone.style.height = `${clone.scrollHeight}px`;
clone.style.overflow = 'visible';
}
});
This is an implementation pattern, not a guarantee for every layout. Nested overflow containers, percentage heights, transforms and sticky descendants can require additional cloned styles. If the panel contains a virtualized list, first render or load the rows that are not currently in the DOM; html2canvas cannot capture nodes that the application has not created.
Tile and stitch very tall panels
For extreme heights, capture vertical sections and combine them in application code. Before each tile, choose a scroll offset, capture a fixed-height region, and draw the resulting canvases onto a larger output or save them separately. Tiling avoids one enormous canvas, but you must account for sticky headers, overlapping shadows and fractional device-pixel coordinates at tile boundaries.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Canvas limits, blank output and clipped images
Evergreen browsers have finite canvas dimensions and areas. The html2canvas FAQ gives approximately 32,767 pixels as a rough current maximum dimension for Chrome/Chromium, Firefox and desktop Safari, while warning that the actual limit varies by browser, operating system, GPU and memory; iOS Safari can be lower. A blank or partially rendered canvas can therefore be a size failure rather than a selector failure.
Estimate the requested pixel size
const cssWidth = target.scrollWidth;
const cssHeight = target.scrollHeight;
const scale = 2;
const pixelWidth = cssWidth * scale;
const pixelHeight = cssHeight * scale;
const pixels = pixelWidth * pixelHeight;
console.log({ pixelWidth, pixelHeight, pixels });
- Reduce
scale, often to1, when the output is blank. - Capture tiles instead of one huge bitmap.
- Remove unnecessary off-screen content from the capture target.
- Prefer a browser automation tool that supports full-page screenshots when a native browser capture is required.
There is no universal safe area threshold. Validate on the browsers and devices you support, especially mobile Safari.
Images, iframes and rendering fidelity
Cross-origin images
With the default allowTaint: false, html2canvas skips images that would taint the canvas. useCORS: true helps only when the image server sends an appropriate Access-Control-Allow-Origin response header:
const canvas = await html2canvas(target, {
windowWidth: target.scrollWidth,
windowHeight: target.scrollHeight,
useCORS: true,
allowTaint: false
});
If the server cannot provide CORS headers, serve the asset through a same-origin proxy you control. Setting allowTaint: true may permit drawing in some cases but can prevent reading the canvas or exporting it, so it is not a general fix for downloadable screenshots.
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
Cross-origin iframes
Cross-origin iframe documents cannot be rendered because browser security rules prevent access to their contentDocument. You can capture the iframe only if it is same-origin and its contents are available to the page, or obtain a screenshot from the framed application itself.
Unsupported CSS and dynamic content
Because html2canvas interprets DOM and styles, unsupported or partially supported CSS can differ from what the browser paints. Wait for fonts, images and application data before calling it; otherwise you may capture fallback fonts, unloaded images or skeleton states. CSS animations can also produce nondeterministic frames, so pause them in the cloned document when repeatability matters.
A reliable capture sequence
- Choose the scope. Select the whole document, a page container or one independently scrollable element.
- Wait for content. Ensure data, images and web fonts needed in the target have finished loading.
- Measure the target. Read
scrollWidthandscrollHeightafter layout has settled. - Prepare the clone. Use
oncloneto expand overflow containers or hide controls that should not appear. - Set scroll coordinates. Use
scrollXandscrollYexplicitly when fixed or sticky elements are involved. - Render conservatively. Start with
scale: 1, then increase it only if the resulting dimensions remain practical. - Export and verify. Check canvas dimensions, inspect the bottom and right edges, and confirm that expected images and fonts are present.
Common failures and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Only the visible viewport appears | Rendering window is still viewport-sized | Set windowWidth and windowHeight from the target’s scroll dimensions. |
| Scrollable panel is cut off | Child overflow remains constrained | Expand the cloned child with onclone, or capture and stitch tiles. |
| Blank canvas | Canvas dimension/area or memory limit | Lower scale, reduce scope, or tile the capture. |
| Images missing | Cross-origin response lacks CORS permission | Enable useCORS with server headers, or use a same-origin proxy. |
| Export throws a security error | Canvas was tainted by an inaccessible image | Fix image CORS or proxy the asset; do not rely on allowTaint for export. |
| Fixed header appears in the wrong place | Scroll coordinates differ from the live page | Set scrollX/scrollY deliberately and test the cloned layout. |
| Iframe is empty | Iframe is cross-origin | Capture it from its own origin or use an external browser screenshot service. |
| Server-side script fails with “window is not defined” | html2canvas requires a browser DOM | Run it in a browser; use Puppeteer or Playwright for server-side automation. |
When html2canvas is the wrong tool
Use html2canvas when the capture can run in the user’s browser, the DOM is accessible, and a reconstructed image is acceptable. It is not suitable for Node.js server rendering because it depends on window, document and computed browser styles.
| Requirement | Best fit |
|---|---|
| Client-side export of a same-origin DOM element | html2canvas with scroll-dimension options |
| Native browser pixels, cross-origin pages or server execution | Puppeteer or Playwright full-page screenshots |
| Very tall output beyond practical canvas limits | Tiled capture or a browser service that handles full-page output |
Compare solutions on capture scope, fidelity, asset access, output-size limits and runtime. A native browser screenshot is generally more faithful; html2canvas is convenient when you need a client-side, DOM-based export without controlling a browser process.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #4
- Scanner type: Document
- Connectivity technology: USB
- With Auto Scan Mode, the scanner automatically detects what you're scanning
- Digitize documents and images
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. One request can return PNG, JPEG, WebP or PDF, so you do not need to install a browser or rewrite a scrollable-page workaround:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Other runnable clients:
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)
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 complete parameter list and response details in the ScreenshotNeo documentation. It can load lazy images, capture full pages or one CSS-selected element, set a viewport or device preset, use retina scale, wait for a selector, delay or network idle, and apply custom CSS or JavaScript. You can also control cookies, headers, user agent, authorization, timezone, geolocation, blocking, caching, PDFs, async webhooks and bulk requests.
- Cookie and consent banners, newsletter popups and chat widgets are removed before the shot.
- Bot checks, blank pages, failed loads and timeouts are not billed; response headers identify the page verdict and billing status. Cache hits are also not billed.
- An MCP server provides
take_screenshot,get_page_infoandcapture_pdffor Claude, Cursor and other MCP clients. - The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Every feature is available on every plan.
Create a free ScreenshotNeo account and start with the 1,000 monthly screenshots without adding a card.
FAQ
Does html2canvas capture content hidden with display: none?
No. Content that is not present in the rendered layout is not painted. Make it part of the cloned layout before capture rather than merely increasing the window size.
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
Can I capture a page longer than 32,767 pixels?
Sometimes, but not reliably as one canvas. Browser limits vary, so use a lower scale or split the output into tiles.
Will increasing windowHeight change responsive styles?
It can. The rendering window participates in media-query evaluation, so verify breakpoints at the dimensions you request.
Is html2canvas a screenshot of the browser’s exact pixels?
No. It reconstructs the DOM and styles in a canvas; the project documents that the result may not be 100% accurate to the real representation.
Frequently Asked Questions
Can html2canvas capture a cross-origin iframe?
No. Browser security prevents access to a cross-origin iframe’s document; capture that application from its own origin instead.
Why does a larger window still leave my scrollable panel clipped?
The panel has its own overflow box. Expand it in the cloned document with onclone, or capture vertical tiles and stitch them.
What is the safest first scale for a full-page capture?
Start with scale: 1, inspect dimensions and output, then increase it only when the resulting canvas remains within your supported browsers’ practical limits.
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.

