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 problemsSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use the canvas that html2canvas() returns, encode it, and trigger an anchor download. The simplest PNG workflow is to await the Promise, call canvas.toDataURL('image/png'), set that value as an anchor’s href, provide a filename through download, and click the anchor. For large captures, encode a Blob and use an object URL instead.
The basic html2canvas download
html2canvas(element) does not return an image file. It returns a Promise that resolves to an HTML canvas. You must encode that canvas before the browser can download it.
async function downloadElementAsPng(element, filename = 'screenshot.png') {
const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = filename;
link.href = canvas.toDataURL('image/png');
link.click();
}
Call the function after a user action, such as a button click:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC 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 & 11const downloadButton = document.querySelector('#download');
const capture = document.querySelector('#capture');
downloadButton.addEventListener('click', async () => {
await downloadElementAsPng(capture, 'dashboard.png');
});
The download value is the suggested filename. Include the extension that matches the MIME type you request. If your page uses a strict Content Security Policy or a framework, keep the same sequence: await the render, encode the canvas, then initiate the anchor download from the event handler.
#1 Best Overall
- USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
- Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
- Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
- Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
- Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty
Use toBlob() for larger images
A data URL contains the entire encoded image in a JavaScript string. That is convenient for small exports, but it can consume more memory for a large or full-page canvas. canvas.toBlob() writes the encoded result to a Blob; URL.createObjectURL() then gives the anchor a temporary URL.
async function downloadElementAsPng(element, filename = 'screenshot.png') {
const canvas = await html2canvas(element);
const blob = await new Promise(resolve => {
canvas.toBlob(resolve, 'image/png');
});
if (!blob) {
throw new Error('Canvas could not be encoded as PNG');
}
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = filename;
link.href = url;
link.click();
// Leave the URL alive briefly so the browser can start the download.
setTimeout(() => URL.revokeObjectURL(url), 1000);
}
Do not revoke the object URL before the browser has had a chance to start the download. If you display the generated URL in an image or another control, keep it until that consumer no longer needs it, then call URL.revokeObjectURL().
Choose an export method
| Method | Best for | Trade-off |
|---|---|---|
toDataURL() plus an anchor |
Short, simple PNG downloads | Builds the complete image as a data URL in memory |
toBlob() plus an object URL |
Large captures and full-page exports | Requires asynchronous Blob handling and URL cleanup |
Both methods require an origin-clean canvas. Neither method can override browser security rules.
Control the capture and filename
Capture a specific element
Pass the element you want rendered instead of the whole document:
const panel = document.querySelector('.invoice');
const canvas = await html2canvas(panel);
Make sure the element has finished laying out before calling html2canvas. Fonts, images, and dynamically inserted content that have not loaded yet can change the result.
Rank #2
- High-speed USB 3.0 performance of up to 150MB/s(1) [(1) Write to drive up to 15x faster than standard USB 2.0 drives (4MB/s); varies by drive capacity. Up to 150MB/s read speed. USB 3.0 port required. Based on internal testing; performance may be lower depending on host device, usage conditions, and other factors; 1MB=1,000,000 bytes]
- Transfer a full-length movie in less than 30 seconds(2) [(2) Based on 1.2GB MPEG-4 video transfer with USB 3.0 host device. Results may vary based on host device, file attributes and other factors]
- Transfer to drive up to 15 times faster than standard USB 2.0 drives(1)
- Sleek, durable metal casing
- Easy-to-use password protection for your private files(3) [(3)Password protection uses 128-bit AES encryption and is supported by Windows 7, Windows 8, Windows 10, and Mac OS X v10.9 plus; Software download required for Mac, visit the SanDisk SecureAccess support page]
Give each download a useful name
const filename = `invoice-${new Date().toISOString().slice(0, 10)}.png`;
await downloadElementAsPng(document.querySelector('#invoice'), filename);
Sanitize user-provided text before placing it in a filename, and avoid path separators. The browser controls the final save location and may adjust the suggested name.
Request another image format
The canvas encoder accepts a MIME type, for example 'image/jpeg' or 'image/webp' where the browser supports it:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
const dataUrl = canvas.toDataURL('image/jpeg', 0.9);
Support is browser-dependent. If the requested type is not supported, toDataURL() can return PNG instead. Inspect the returned data URL’s MIME prefix when the exact format matters, and keep the filename extension consistent with the actual result.
Fix tainted-canvas and missing-image errors
Why remote images disappear
html2canvas reconstructs a representation from DOM and CSS information; it is not a literal browser screenshot. A remote image can make the canvas tainted when the image server does not grant cross-origin access. A tainted canvas cannot be read with toDataURL() or toBlob().
Enable CORS when the image host allows it
If the image server sends an appropriate Access-Control-Allow-Origin response header, request CORS-aware loading:
Rank #3
- What You Get - 2 pack 64GB genuine USB 2.0 flash drives, 12-month warranty and lifetime friendly customer service
- Great for All Ages and Purposes – the thumb drives are suitable for storing digital data for school, business or daily usage. Apply to data storage of music, photos, movies and other files
- Easy to Use - Plug and play USB memory stick, no need to install any software. Support Windows 7 / 8 / 10 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, compatible with USB 2.0 and 1.1 ports
- Convenient Design - 360°metal swivel cap with matt surface and ring designed zip drive can protect USB connector, avoid to leave your fingerprint and easily attach to your key chain to avoid from losing and for easy carrying
- Brand Yourself - Brand the flash drive with your company's name and provide company's overview, policies, etc. to the newly joined employees or your customers
const canvas = await html2canvas(element, { useCORS: true });
useCORS is false by default. The option only works when the remote server is configured to allow your origin (or otherwise permits the request). Check the image request in browser developer tools and verify its response headers.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Use a proxy when you control neither origin
When the image host does not send the required header, serve the image through a server-side proxy that you control and configure that proxy to return suitable CORS headers. Do not assume that setting allowTaint: true makes export possible; it does not make a tainted canvas readable under browser security rules.
Cross-origin iframes
html2canvas cannot render the contents of a cross-origin iframe when browser security prevents your page from accessing that document. You can capture the iframe element’s surrounding layout, but not secretly read and redraw its protected contents. A capture service that loads the target page itself is a different approach.
Understand what the output represents
The project describes html2canvas as allowing “screenshots” of webpages or parts of them directly in the user’s browser, while clarifying that it renders from DOM information rather than taking an actual screenshot. It only implements the CSS and browser features it understands. Pixel-for-pixel parity with the visible browser window is therefore not guaranteed.
- Unsupported CSS or unusual browser effects may be absent or look different.
- Images and other resources must be available at capture time.
- Layout changes between the initial page render and the call can appear in the result.
- A successful Promise means a canvas was produced, not that every visual resource was reproduced exactly.
Make downloads reliable in production
Wait for content before rendering
Call html2canvas only after the component is mounted and its content is ready. For application-generated images, wait for the image’s load event before capturing. If your UI changes state immediately before the click, wait for the next render cycle so the DOM reflects that state.
Recommended Free Tools
Rank #4
- GOOD VALUE PACKAGE - 1 Pack 32GB Memory Stick USB 2.0 Flash Drives with great cost performance and high quality.
- BIG CAPACITY - The available capacity: 29.10GB-29.8GB, You can save the data of movies, music, photos, designs, programs, manuals, handouts in a high speed.Good performance in digital data storing, transferring and sharing with families, friends, workmates, clients and machines.
- EASY TO USE & PLUG AND WORK - Support windows 7 / 8 / 10 / Vista / XP / 2000 / ME / NT Linux and Mac OS, Compatible with USB2.0 and below.
- TWISTTURN DESIGN & EASY CARRY - The metal clip rotates 360° round the ABS plastic body which with rubber oil skin feeling finish. The capless design can avoid lossing of cap, and providing efficient protection to the USB port.
- WARRANTY & SUPPORT - SIMMAX logo is laser printed on the USB connector surface, our products are of good quality and we promise that any problem about the product within one year since you buy.
Handle failures explicitly
downloadButton.addEventListener('click', async () => {
downloadButton.disabled = true;
try {
await downloadElementAsPng(document.querySelector('#capture'));
} catch (error) {
console.error('Screenshot export failed', error);
alert('The screenshot could not be exported. Check remote images and try again.');
} finally {
downloadButton.disabled = false;
}
});
Keep the failure path visible to the user. A rejected render Promise, a null Blob, or a security exception should not leave the interface permanently disabled.
Reduce memory pressure
- Prefer the Blob/object-URL path for very large canvases.
- Capture the smallest necessary element instead of an entire page when possible.
- Release object URLs after the download has started.
- Avoid retaining old canvases and data URLs in application state.
Troubleshooting checklist
| Symptom | Likely cause | Fix |
|---|---|---|
SecurityError from toDataURL() or toBlob() |
The canvas is tainted by cross-origin content | Use useCORS: true only when the image server sends the required CORS header; otherwise proxy the asset |
| Images are missing | Resources are cross-origin, not loaded yet, or blocked | Inspect network requests, wait for loading, and configure CORS or a proxy |
| The downloaded file is PNG despite another requested type | The browser does not support the requested encoder | Inspect the data URL MIME type and use the matching extension |
| The result does not match the browser exactly | html2canvas is a DOM/CSS reconstruction | Check supported rendering features and simplify unsupported effects |
| The button appears to do nothing | The Promise rejected or the download was blocked by the surrounding code | Add try/catch, log the error, and trigger the anchor from the user event |
| Large exports freeze the tab | Encoding a very large data URL creates memory pressure | Use toBlob(), capture a smaller element, and release object URLs |
Or skip the browser setup
If you need a server-side screenshot of a URL rather than a DOM capture inside your current page, ScreenshotNeo provides a single HTTP request that returns PNG, JPEG, WebP, or PDF. 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; the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server also exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
cURL
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 authentication, output options, and the full parameter set. In addition to full-page captures, it supports CSS-selector element shots, dark mode, device presets and custom viewports, retina scale, custom CSS and JavaScript, click and wait actions, blocked requests or resource types, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, TTL-based caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification. Parameters used by other screenshot APIs also work, which can simplify migration.
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000 per month | $0, no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing gives two months free, and every feature is available on every plan. The free tier includes 1,000 screenshots a month with no card. Create a free ScreenshotNeo account to try the API.
FAQ
Does html2canvas save a file by itself?
No. It resolves to a canvas. Your code must encode that canvas and initiate the download.
Can I export a cross-origin image with JavaScript alone?
Not when the image server denies cross-origin access. The server must allow CORS, or the image must be supplied through a suitable proxy.
Best Value
- 【16GB Flash Drive】USB flash drives with 16GB capacity, meet your needs of daily use on work, school, home and travelling for photos, music, videos, files storage and transfer. IMEASON thumb drives can be used to store different files, easy to data backup.
- 【Metal Swivel Cap Design】USB thumb drive is metal swivel cover provides extra protection for the usb thumbdrive connector, no usb drive cap to lose; keychain design makes it easier to carry without worrying lose it.
- 【Wide Compatibility】USB drive supports Windows 7/8/10/11 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, also Supports USB 2.0 and 1.1 ports. USB Stick support TV, desktop, notebook computer, car, audio and other device. The USB Memory Stick is your great data storage and transfer companion with traveling and working.
- 【Easy to use】usb memory stick is plug and play without any software installation. Just simply plug the Flashdrive into the port of your USB-compatible devices such as computer, laptop to start data storage or transmission.
- 【What You Get】16 GB USB Flash Drive Thumb Drive, The default format of the usb storage flash drive is FAT32.
When should I prefer ScreenshotNeo?
Use it when you need a URL-level capture, PDF output, automated cleanup of consent UI, or an MCP workflow instead of rendering the current page in the user’s browser.
Frequently Asked Questions
Does html2canvas save a file by itself?
No. It resolves to a canvas; your code must encode the canvas and initiate the download.
Free tools Windows power users keep installed
One-click scans. No signup required.
Can I export a cross-origin image with JavaScript alone?
Only when the image server permits CORS. Otherwise use a suitable proxy.
When should I prefer ScreenshotNeo?
Choose it for URL-level captures, PDF output, consent and popup cleanup, or MCP-based automation.
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.

