To capture a full page with html2canvas, render the document element and set windowWidth and windowHeight to its scrollWidth and scrollHeight. This gives the cloned page a rendering window large enough to lay out the full document. The result is a canvas—not a native screenshot—and very long pages can exceed browser canvas limits.
Capture the full document
Install and load html2canvas in your browser app, then pass the element containing the content you want. For the whole document, document.documentElement is a useful target. The library’s FAQ demonstrates this pattern:
const element = document.documentElement;
const canvas = await html2canvas(element, {
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
});
Ensure the script has loaded before calling it. For example, in a page that loads html2canvas from a local bundle:
async function captureFullPage() {
const element = document.documentElement;
const canvas = await html2canvas(element, {
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
});
const link = document.createElement('a');
link.download = 'screenshot.png';
link.href = canvas.toDataURL('image/png');
link.click();
}
captureFullPage();
In a typical page, document.body may be the better capture target if it contains exactly the content you want. Measure the selected element itself. If the body is narrower or shorter than the document element, use the document element’s dimensions only when that is what you intend to render.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minute#1 Best Overall
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 4x optical zoom with a 27mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen with 2 AA alkaline batteries for convenient on-the-go use
The project documents windowWidth and windowHeight as cloned-window dimensions. They influence layout and media-query evaluation; they do not merely stretch the final bitmap. See the html2canvas FAQ and configuration reference.
Prepare the page before measuring
- Wait for the content you need. If your app fetches data or renders components asynchronously, wait for those operations before calling html2canvas.
- Load important images. Wait for images that must appear in the output. A capture only reconstructs content present in the DOM at render time.
- Trigger lazy content. If images or sections load as the visitor scrolls, scroll through the needed content or otherwise trigger its loading, then wait for it to finish before measuring.
- Choose a target and measure it. Use the target’s actual
scrollWidthandscrollHeightfor a full-content capture. - Pick the intended responsive width. A document’s full scroll width can differ from the visitor’s viewport width. Because the cloned window affects media queries, decide whether the capture should reflect the current breakpoint or a wider layout.
- Capture and inspect. Check the resulting image at the output size you need. Tall captures can be blank or cut off if they exceed canvas limits.
A target element might have a large scroll height but contain a scrollable region rather than a full page. In that case, decide whether you need the element’s full internal content or the overall document. The element supplied to html2canvas determines what it attempts to reconstruct.
Export the canvas as an image
The returned value is a canvas. The project’s example exports it as a PNG using a temporary download link:
const canvas = await html2canvas(document.body, {
windowWidth: document.documentElement.scrollWidth,
windowHeight: document.documentElement.scrollHeight,
});
const link = document.createElement('a');
link.download = 'screenshot.png';
link.href = canvas.toDataURL('image/png');
link.click();
For application workflows that need a file object instead of a data URL, use the canvas blob API:
const canvas = await html2canvas(document.documentElement, {
windowWidth: document.documentElement.scrollWidth,
windowHeight: document.documentElement.scrollHeight,
});
canvas.toBlob((blob) => {
if (!blob) {
throw new Error('Canvas could not be exported');
}
const file = new File([blob], 'screenshot.png', { type: 'image/png' });
// Pass `file` to your upload or file-handling code.
}, 'image/png');
Data URLs are convenient for a direct download, while a blob is generally a more practical form for file handling. Both methods still depend on the canvas being exportable; cross-origin content can affect that, as described below.
Rank #2
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
Control size, scale, and what is included
Keep the responsive layout intentional
windowWidth affects the cloned page’s viewport for layout calculations. Setting it to a long document’s scrollWidth may select a different responsive breakpoint than the visible browser window. If the screenshot should match the current viewport layout, use that intended width deliberately rather than assuming the document’s scroll width is always right.
Use scale carefully
The documented default for scale is window.devicePixelRatio. A higher scale increases output pixel dimensions and pixel area, which can increase memory use and make canvas-size limits more likely on long pages. Lowering scale can make a large capture more manageable, at the cost of resolution. The configuration reference also documents width and height for controlling canvas dimensions.
Crop or adjust the cloned DOM
For a section or crop rather than the entire page, pass the desired element or use the documented x, y, width, and height options. To change or omit content in the cloned render, use onclone or mark excluded elements with data-html2canvas-ignore. These affect the reconstructed output, not the live page’s original DOM. See the configuration options and official examples.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Know what html2canvas can and cannot reproduce
html2canvas does not take a literal screenshot of the browser’s final pixels. It reads DOM and style information and reconstructs an image using the CSS features it implements. The project explains: “The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.” See About html2canvas.
That distinction matters when fidelity is important: some CSS properties are not implemented, so visual differences are expected on pages that rely on them. Plugin content such as Flash or Java applets is not rendered. Check the project’s supported features and test the actual page and browser combination you use.
Rank #3
- Latest Digital Camera Built-in Fill Light : This compact digital camera is paired with a powerful CMOS processor and image stabilization to help you take & record the most exciting moments in 44 MP quality images & FHD 1080P quality videos anywhere, anytime. Plus, there is also a built-in fill light to help you take high quality pictures even in low light&dark settings, making this the perfect camera for all indoors/outdoors situations.
- Long-Lasting Battery Life & 16X Digital Zoom :This point and shoot camera will retain its battery charge even after long use. The controls and functions are easy to operate making this the perfect choice for children, teens and younger. This kids camera supports 16x digital zoom, you can zoom in or out the subject by pressing the W/T button for taking still photos to zoom in or out on distant objects and capture all the details you need.
- Multifunctional & Portable Digital Camera: This cheap digital camera is slim enough to fit in your pocket. You'll easily be able to take it with you on all your indoor/outdoor activities and adventures and ideal for beginners, children and teenagers. This kids digital camera is equipped with 20 filters, anti-shaking, self-timer, continuous shooting, date stamp, time-lapse recording, smile capture, internal MIC and speaker (recording sound videos), great for your daily photography needs.
- WEBCAM & PAUSE FUNCTION : More than just a FHD 1080p digital camera, it also works as a webcam for video calls and vlogging. Connect the camera to the computer, press shutter and power button at the same time and the camera will automatically turn on webcam mode for all your video calling and live streaming needs. The pause function allows you to pause when seeing playback videos.
- A Must Have Photography Device : This digital camera with SD card made from high-quality materials, this retro camera is safe and durable. Perfect for all ages to develop & improve their photographic abilities and observation skills. Our dedicated and experienced 24/7 support team is available for all after purchase troubleshooting, questions and technical help.
Fix missing cross-origin images and iframe content
Browsers restrict reading pixels drawn from resources on another origin. By default, html2canvas skips a cross-origin image when including it would taint the canvas. Setting useCORS: true can help only if the image server sends compatible CORS headers, such as an appropriate Access-Control-Allow-Origin response.
const canvas = await html2canvas(document.documentElement, {
windowWidth: document.documentElement.scrollWidth,
windowHeight: document.documentElement.scrollHeight,
useCORS: true,
});
If the server does not allow cross-origin access, a proxy that retrieves the resource is another documented option. allowTaint: true does not grant permission to read a tainted canvas or bypass browser security. Consult the FAQ and proxy documentation.
Recommended Free Tools
Same-origin iframe documents can be rendered recursively. A cross-origin iframe cannot be read through contentDocument, and a sandboxed iframe without allow-same-origin presents the same access barrier. This is a browser security boundary, not a missing html2canvas option.
Understand canvas limits on tall pages
Canvas limits vary by browser release, platform, hardware, and available memory. The html2canvas FAQ gives rough guidance for current evergreen browsers—not guaranteed supported limits—including a maximum dimension around 32,767 pixels for Chrome/Chromium, Firefox, and desktop Safari. Its cited approximate maximum canvas areas are around 268 million pixels for Chrome/Chromium and 472 million pixels for Firefox. Safari on iOS has lower limits that depend on device RAM.
Exceeding a limit can produce a blank or partial canvas without an error. A high device pixel ratio or an increased scale makes the rendered bitmap larger, so reduce scale or capture smaller sections if output fails. The FAQ points to the canvas-size library for updated tests across browser and platform combinations; treat any limit figures as estimates, not guarantees.
Rank #4
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
Or skip the browser setup
If you need a screenshot from code without running html2canvas in the page, ScreenshotNeo is a website screenshot API and MCP server. A GET request returns an image or PDF. For a PNG capture of a page, use the API endpoint as shown here; the ScreenshotNeo documentation covers request options.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://stripe.com
-o shot.png
ScreenshotNeo accepts and removes cookie or consent banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for 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 shots. Sign up free for 1,000 screenshots a month, with no card required.
When a native browser capture is the better fit
Browser extensions
For a browser extension, the html2canvas FAQ recommends native tab-capture APIs instead: chrome.tabs.captureVisibleTab() for Chrome-family extensions and browser.tabs.captureVisibleTab() for Firefox. The FAQ describes these as more reliable and not subject to canvas-size limits. They capture a visible tab, so extension-specific capture needs should determine whether that is sufficient.
Server-side screenshots
html2canvas depends on browser APIs such as window, document, and computed styles, so it is unsuitable for server-side screenshot generation. For that use case, the FAQ points to driving a real headless browser with Puppeteer or Playwright. See the html2canvas FAQ.
Troubleshooting common failures
| Symptom | Likely cause | What to try |
|---|---|---|
| Only the visible viewport appears | The cloned rendering window is limited to the viewport, or the wrong element was measured. | Pass the intended full-content element and set both window dimensions from that element’s scroll dimensions. |
| The image is blank or cuts off partway down | The capture may exceed browser canvas dimensions or area, especially at high scale. | Reduce scale, capture smaller sections, and test on the target browser and device. Limits vary and can fail silently. |
| External images are missing | The image host does not allow the required cross-origin access, or the image is not loaded yet. | Wait for image loading; use useCORS: true only when the server sends compatible CORS headers, or use a proxy. |
| Export fails after drawing external content | The canvas may be tainted by content the browser does not permit the page to read. | Use a CORS-authorized resource or proxy. allowTaint cannot bypass the restriction. |
| The layout differs from the browser view | html2canvas reconstructs the page and does not implement every CSS property; the cloned window width can also activate another breakpoint. | Check supported CSS features and set the intended windowWidth; inspect the actual page’s output. |
| Iframe content is absent | The iframe is cross-origin or sandboxed without allow-same-origin. |
Only accessible same-origin iframe documents can be rendered recursively; browser security prevents reading the others. |
| Lazy-loaded sections or images are missing | They were not yet added to the DOM or loaded when capture began. | Trigger their loading, wait for completion, then measure and call html2canvas. |
Frequently Asked Questions
Does html2canvas capture an exact screenshot of the browser?
No. It reconstructs the image from DOM and style information, so unsupported CSS and browser-rendering details can cause differences.
Can html2canvas capture a cross-origin iframe?
No. The browser does not expose a cross-origin iframe’s document to the page; same-origin iframe documents can be rendered recursively.
Can I use html2canvas in Node.js for server-side screenshots?
No. It depends on browser APIs such as window and document; use a headless-browser approach such as Puppeteer or Playwright for server-side capture.
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.




