Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Use html2canvas in the browser: select the element, await html2canvas(element), then export the returned canvas as a PNG. This renders the element’s DOM and supported styles; it is not a pixel-perfect native screenshot, and browser security rules still apply to cross-origin images and frames.
Capture and download a div as a PNG
html2canvas runs in the browser. It traverses the page’s DOM and styles to draw a representation onto a canvas, so it works well for ordinary HTML and CSS when you need to export part of the page without sending it to a screenshot server. It does not simply photograph the browser’s rendered pixels.
The example below uses a small Vite project so the npm-installed package can be imported as a JavaScript module. It captures the element with the ID capture when the user presses the button, then downloads a PNG.
1. Create the project and install html2canvas
npm create vite@latest div-capture -- --template vanilla
cd div-capture
npm install
npm install html2canvas
npm run dev
Open the local address printed by Vite. Replace the contents of index.html with the following. The module script imports the dependency installed in the project.
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 →#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
2. Add a target element and download button
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Capture a div</title>
<style>
body { font: 16px sans-serif; margin: 2rem; }
#capture { background: #f2f5f8; padding: 2rem; max-width: 32rem; }
</style>
</head>
<body>
<div id="capture">
<h2>Invoice</h2>
<p>This content will be rendered into an image.</p>
</div>
<p><button id="save" type="button">Download PNG</button></p>
<script type="module" src="/src/main.js"></script>
</body>
</html>
Put this in src/main.js:
import html2canvas from 'html2canvas';
document.querySelector('#save').addEventListener('click', async () => {
const element = document.querySelector('#capture');
if (!element) throw new Error('The #capture element was not found');
try {
const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = 'capture.png';
link.href = canvas.toDataURL('image/png');
link.click();
} catch (error) {
console.error('Could not capture the element:', error);
}
});
Click Download PNG. The browser should save capture.png. The await matters: rendering is asynchronous, so export only after html2canvas has resolved with the canvas.
Use the browser script release instead of npm
The project also supports a built script-tag release. If you use that installation method, load the library before the code that calls html2canvas, then use the same element-selection, rendering and export steps. For an application with a build setup, the npm import above makes the dependency explicit.
Choose the output format and download method
canvas.toDataURL('image/png') creates a data URL that can be assigned to an anchor’s href. It is convenient for a direct browser download and is the approach in the example. For workflows that upload the image or need a Blob rather than a large in-memory data URL, use toBlob():
const canvas = await html2canvas(element);
canvas.toBlob((blob) => {
if (!blob) {
console.error('The browser could not create the image blob');
return;
}
const objectUrl = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = objectUrl;
link.download = 'capture.png';
link.click();
URL.revokeObjectURL(objectUrl);
}, 'image/png');
For an upload, pass the Blob to the upload code instead of creating a download link. Choose the MIME type explicitly if you need a format other than PNG, and check the browser’s supported canvas export formats for the target environment.
Free tools Windows power users keep installed
One-click scans. No signup required.
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)
Set capture size, sharpness, background and crop
Pass an options object as the second argument: html2canvas(element, options). The following settings are useful when the default capture does not match the intended output.
const canvas = await html2canvas(element, {
scale: window.devicePixelRatio,
backgroundColor: null,
width: element.scrollWidth,
height: element.scrollHeight,
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
});
scale: controls the output pixel density. It defaults to the device pixel ratio; a higher scale can make the image sharper, but also increases its pixel dimensions and memory use.backgroundColor: defaults to white. Set it tonullwhen you want a transparent background and the chosen output format supports transparency.widthandheight: set the rendered canvas dimensions. For an element that extends beyond its visible box, itsscrollWidthandscrollHeightcan be useful values.windowWidthandwindowHeight: set the dimensions of the window used for rendering. For a tall element that is being cut off, the project FAQ recommends matching these to the element’s scroll dimensions.x,y,widthandheight: define a crop when you want a specific rendered area rather than the whole target.scrollXandscrollY: control the scroll position used for fixed-position content. This can change where fixed elements appear in the result.
Large captures are subject to browser canvas size limits, which vary by browser and device. If a full-height result is blank, truncated or fails to export, try a smaller scale, a narrower capture, or several smaller sections rather than assuming the element selector is wrong.
Capture only the content you want
You can exclude unwanted page elements without removing them from the live page. Set data-html2canvas-ignore on an element that should not appear, or use the ignoreElements option to exclude nodes programmatically. This is useful for hiding controls such as the download button, but should not be used to alter content the image is supposed to preserve.
The onclone option lets you change the cloned document used for rendering. For example, you can adjust a class or remove a temporary element in that clone without changing the original page the user is viewing. Use it when capture-only styling is needed; do not mutate the live UI just to prepare an export.
Rank #3
- STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
- CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
- HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
- FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
- BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer
Why images may be missing or the export may fail
Browser cross-origin rules apply to canvas content. html2canvas cannot bypass those rules. An image loaded from another origin can be omitted, or it can taint the canvas so that reading or exporting the result fails.
- Try
useCORS: trueonly when the image host permits it. The remote server must return an appropriateAccess-Control-Allow-Originresponse header. Setting the option does not grant permission by itself. - Use a same-origin proxy if the remote server cannot provide the required header. html2canvas has a
proxyoption; the proxy must be configured to fetch the image safely and make it available to the browser under your origin. - Check existing canvas elements as well. A canvas already tainted by cross-origin content remains unreadable, even if the new capture otherwise succeeds.
- Inspect frames and embedded content. Same-origin iframes are supported recursively. A cross-origin iframe cannot be read because its
contentDocumentis inaccessible to the page. Plugin content such as Flash or Java applets is not rendered.
For a CORS-enabled image host, add useCORS: true to the call:
const canvas = await html2canvas(element, { useCORS: true });
If the host does not send the necessary CORS header, this setting alone is not a fix. Arrange for the asset to be served with permission, use an appropriately configured same-origin proxy, or accept that the asset cannot be included in a client-side export.
Know what html2canvas can and cannot reproduce
Because the library reconstructs an image from DOM nodes and CSS properties it understands, its output can differ from the browser’s actual composited pixels. Unsupported CSS may not render as expected. A successful call is therefore not a guarantee of pixel-for-pixel equivalence with a native browser screenshot.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsRank #4
- IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
- IRIScan Express mobile scanner is powered via an included micro USB 2. 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. USB cable provided. AC Adapter not provided and not needed.
- IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
- IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
- Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management
html2canvas is a good fit when the target is ordinary DOM/CSS content and the capture should run on the user’s browser. Consider a browser screenshot or a server-side rendering workflow when the requirement is a native view of the browser output, the page depends on content html2canvas cannot access, or the capture must run without a user’s browser. Compare alternatives by pixel fidelity, cross-origin and iframe coverage, whether client-side execution is required, output-size limits and the need for browser automation or a Node-compatible renderer.
The project documents support for modern evergreen Chrome/Chromium, Firefox and Safari. That compatibility statement does not mean every CSS feature or browser-specific page will render identically; check your actual target browsers and content.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If you need a screenshot of a page by URL rather than an in-browser rendering of one specific DOM node, ScreenshotNeo is a website screenshot API and MCP server. It captures a URL as PNG, JPEG, WebP or PDF; it is not a drop-in replacement for selecting an arbitrary client-side div. Its API can be called with one GET request. See the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
For scripts or applications, the same request can be made with Python or Node.js:
Best Value
- Scanner type: Document
- Connectivity technology: USB
- With Auto Scan Mode, the scanner automatically detects what you're scanning
- Digitize documents and images
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}`);
- Cookie and consent banners are accepted and removed before capture, along with 60+ known consent platforms, newsletter popups and chat widgets; each of those steps can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing. The response includes
X-Page-VerdictandX-Billedheaders to say which outcome occurred. - An MCP server provides
take_screenshot,get_page_infoandcapture_pdftools for AI agents, including 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; yearly billing gives two months free, and every feature is on every plan.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Troubleshooting checklist
| Symptom | Likely cause | What to try |
|---|---|---|
| The result is blank or the target is missing. | The selector did not match an element, or the content was not ready when capture began. | Check that document.querySelector('#capture') returns the intended element. Wait until application data and images have loaded before calling html2canvas. |
| Remote images are absent. | The image host did not permit cross-origin access. | Use useCORS: true only if the host returns an appropriate CORS header; otherwise use an authorized same-origin proxy or change the asset’s serving configuration. |
| The image looks cut off vertically. | The render used viewport-like dimensions or the canvas exceeded browser limits. | Try windowWidth and windowHeight based on scrollWidth and scrollHeight. If still too large, reduce scale or capture sections separately. |
toDataURL() throws or export fails. |
The canvas may have been tainted by cross-origin content. | Resolve CORS or proxy access for the offending assets. A tainted source canvas also remains unreadable. |
| Some styling differs from the page. | html2canvas recreates the DOM using supported CSS rather than taking a native screenshot. | Check the affected CSS and simplify or adjust it for capture; use a native browser screenshot workflow if exact compositor output is required. |
| An iframe or embedded object is missing. | Cross-origin frames are inaccessible; plugin content is not rendered. | Capture same-origin frame content where appropriate. A page cannot read a cross-origin frame’s document; choose a workflow that can capture the content with proper access. |
Frequently asked questions
Can html2canvas run in Node.js by itself?
No. It depends on browser APIs and runs in a browser. A Node-only script needs a browser automation or server-side rendering approach instead.
Does html2canvas make a native screenshot?
No. It builds a canvas representation by traversing DOM and styles. Its output can differ from the browser’s actual pixels.
Can I use it on any div?
You can pass a selected element, but the output depends on content the browser can access and CSS the renderer understands. Cross-origin frames, restricted images, plugins and unsupported styles can affect the result.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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.

