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 →The dependable browser workflow is HTML element → html2canvas canvas → image data URL → temporary download link. Select the element, wait for html2canvas() to finish, export the returned canvas as PNG, and trigger an anchor with a download filename. The method runs entirely in modern browsers, but it reconstructs the DOM rather than photographing browser pixels, so unsupported CSS and unauthorized cross-origin images can change or break the result.
What you are actually generating
HTML and CSS are instructions for a browser, not an image file. To let a visitor save a styled card, invoice, chart, or other element, a client-side renderer must turn that element into pixels. html2canvas walks the DOM, reads the styles it understands, paints a representation onto a canvas, and exposes the canvas for export.
This distinction matters. The html2canvas documentation explains that it “does not actually take a screenshot of the page, but builds a representation of it based on the properties it reads from the DOM.” CSS that the library does not support may be missing or rendered differently. Test the exact components your design uses before treating the output as a pixel-perfect browser screenshot.
Basic browser implementation
Install and import html2canvas
In a project that uses npm and a browser bundler, install the package:
#1 Best Overall
- User-Friendly Portable Photo Printer for iPhone, Android & PC - Get beautiful and colourful memories with Liene 4x6 photo printer! After opening the entire package, you can find one cartridge + 20 sheets of photo paper (placed inside the machine packaging), as well as an additional box containing 80 sheets of photo paper (which includes two cartridges + 80 sheets of photo paper). Full package includes smartphone photo printer, Liene 4x6 photo printer papers (100 sheets), 3 colour cartridges, and fully sealed cassette to prevent dust. Minimalist and magnetic design for compact storage.
- Superior Quality 4x6 Photo Printer - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Clean the print head promptly if smudges are observed on printed photos during operation. Get Liene photo printers now for yourself and your loved ones, print your happy moments together and keep your love forever!
- Wi-Fi Photo Printer for Smartphone - The built-in hotspot of the photo printer makes it easy to print pictures from your phone, avoiding outside interference with a fast and stable connection. No other networks required! Simply connect your device to the independent instant photo printer 4x6 hotspot.
- Multiple Device Compatibility - Liene phone printer provides instant photo printing for up to 5 simultaneous connections. Share with family and friends or print from your different devices. No additional cables or Bluetooth required when printing photos with this picture printer. Note: Ensure the ink cartridge clicks into place before printing.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Square border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this photo printer for iphone 4x6 prints.
npm install html2canvas
Then import it from your application code. The following example captures a card and downloads a PNG when the button is clicked.
import html2canvas from "html2canvas";
const button = document.querySelector("#download-card");
const target = document.querySelector("#card");
button.addEventListener("click", async () => {
button.disabled = true;
try {
const canvas = await html2canvas(target, {
backgroundColor: "#ffffff",
scale: window.devicePixelRatio || 1
});
const link = document.createElement("a");
link.download = "my-card.png";
link.href = canvas.toDataURL("image/png");
link.click();
} catch (error) {
console.error("Could not create image", error);
alert("The image could not be created. Check the console for details.");
} finally {
button.disabled = false;
}
});
The matching markup can be as simple as:
<article id="card" class="card">
<h1>Launch day</h1>
<p>A styled HTML element that can be saved as an image.</p>
</article>
<button id="download-card" type="button">Download PNG</button>
Call html2canvas() only after the target is in the document and its fonts and images have loaded. The returned value is a Promise, so the download must be created inside await or .then().
A standalone capture function
Separating capture from the click handler makes it easier to reuse for several elements:
import html2canvas from "html2canvas";
export async function downloadElementAsPng(element, filename = "download.png") {
if (!element) throw new Error("A target element is required");
const canvas = await html2canvas(element, {
scale: Math.max(1, window.devicePixelRatio || 1),
backgroundColor: "#fff",
useCORS: true
});
const anchor = document.createElement("a");
anchor.download = filename;
anchor.href = canvas.toDataURL("image/png");
anchor.click();
}
useCORS: true asks the renderer to request images with CORS enabled. It does not grant permission by itself; the image host must send suitable CORS headers, or you must serve the asset through an appropriate same-origin proxy.
Control the captured area and output quality
Capture one element
Pass a DOM node, commonly selected with document.querySelector(). The element’s rendered dimensions become the canvas bounds. If you need a predictable export, give the element explicit width, padding, and background styles instead of relying on content that can reflow.
Increase resolution with scale
The scale option multiplies the output resolution. A value of 2 creates twice as many pixels in each dimension (four times the pixel area), which is useful for high-DPI displays and print-oriented cards. Larger canvases consume more memory; choose the smallest value that meets your output requirement. window.devicePixelRatio follows the current display and can produce different file dimensions on different screens, so use a fixed value when reproducibility matters.
Rank #2
- Dock Photo Printer: The KODAK Dock Plus is a home photo printer that produces high-quality 4x6” prints directly from compatible smartphones. Featuring an integrated docking station, users can place their phone on the printer for better connection while simultaneously charging the device during printing.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Dock Plus is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Home Printing Station: Designed for stable desktop use, this dock photo printer connects to a power outlet for consistent performance and larger 4x6” prints. Ideal for home printing, photo albums, framing, family events, and everyday picture printing.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
const canvas = await html2canvas(target, {
scale: 2,
backgroundColor: "#f7f7f7"
});
Make the background transparent
Set backgroundColor: null when the image should preserve transparency. A page or element with no painted background otherwise receives the default background chosen by the renderer.
const canvas = await html2canvas(target, {
backgroundColor: null
});
Exclude controls and private content
Add data-html2canvas-ignore to any element that should not appear, such as the download button, editing handles, or a “close” icon:
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 minuteWindows 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 reinstall<button data-html2canvas-ignore id="download-card">Download</button>
You can also hide elements in an onclone callback. html2canvas renders a cloned document, so these changes do not alter what the visitor sees:
const canvas = await html2canvas(target, {
onclone: (clonedDocument) => {
clonedDocument.querySelectorAll(".editing-only").forEach((node) => {
node.style.display = "none";
});
}
});
Capture a region instead of a whole element
When the target is larger than the desired crop, pass viewport coordinates and dimensions with x, y, width, and height. Coordinates are relative to the document or viewport according to the capture context, so verify the crop visually on pages that scroll or use transformed containers.
const canvas = await html2canvas(document.body, {
x: 120,
y: 80,
width: 640,
height: 360,
scale: 2
});
Images, fonts, and CSS that commonly change the result
Cross-origin images
Canvas security rules prevent script from safely reading pixels from an image that came from another origin without permission. If a remote image lacks the required CORS response headers, the canvas can become tainted and toDataURL() can fail. The browser’s same-origin policy still applies; useCORS cannot bypass it.
- Serve the image from the same origin as the page.
- Configure the image server to allow your page’s origin with appropriate CORS headers.
- Use a server-side, same-origin proxy that you control, subject to the remote site’s terms and access rules.
- Use a local or embedded asset when that is practical.
Check the browser Network and Console panels for blocked image requests before changing renderer options.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- 2x3" Portable Photo Printer: The upgraded PP01 photo printer uses advanced inkjet technology. This portable photo printer produces vivid, full-color prints on premium sticky-backed photo paper that is smudge-proof, water-resistant, and tear-resistant. The Nelko mini photo printer is pocket-sized and weighs only 308g, making it ultra-portable for school, travel, and field trips. Each ink cartridge prints up to 80 full-color 2x3 photos on sticky-backed paper
- Easy Printing via Bluetooth: The PP01 mini photo printer is compatible with iOS and Android phones via Bluetooth. Simply download the Nelko app from Google Play or the App Store. Load the 2x3 photo paper with the smooth side facing down. Install the ink cartridge, connect via Bluetooth, and print directly using the Nelko app. A USB charging cable is included; the adapter is not included
- High Photo Quality: This mini photo printer uses advanced inkjet technology for clear, vibrant prints. This portable photo printer produces 600 DPI high-resolution images with precise colors, capturing fine details and realistic tones. Each photo comes with adhesive backing, perfect for scrapbooks and preserving your memories. Personalize every photo for holidays, birthdays, or daily events
- Powerful App: The Nelko 2x3" PP01 photo printer app lets you edit photos and offers a variety of frame designs, making it perfect for personalizing your photos for projects like scrapbooking or journaling. Download the Nelko app to create collages and customize photos with filters, graffiti, borders, stickers, text, AI image editing, and many other features. Edit photos on your phone, then send them to the Nelko app for instant printing in under 90 seconds
- Versatile Usage Scenarios: This portable photo printer is ideal for travel journals, party favors, and family gatherings. Students use it for planners and photo printing. Crafters use it for DIY projects, custom labels, and scrapbooking. It's a practical tool for bloggers, small businesses, and event photographers to create instant giveaways. Perfect for Mother's Day surprises and heartfelt moments with loved ones using Nelko sticky-backed photo paper.
Unsupported or complex CSS
html2canvas supports many common styles but not the complete CSS specification. Effects or layout features it cannot interpret can be absent or approximate. Pay particular attention to complex filters, unusual blend modes, generated content, advanced transforms, and browser-native controls. Compare the exported image with the live element in Chrome, Firefox, and Safari if those browsers are part of your support target.
Fonts and delayed content
Capture after web fonts, images, and asynchronous data have finished loading. A practical pattern is to wait for document fonts and image elements:
await document.fonts.ready;
await Promise.all(
[...document.images].map((image) =>
image.complete
? Promise.resolve()
: new Promise((resolve) => {
image.addEventListener("load", resolve, { once: true });
image.addEventListener("error", resolve, { once: true });
})
)
);
const canvas = await html2canvas(target);
This prevents an avoidable blank image, but it cannot make a failed resource available or add CORS permission that the server did not provide.
Choose PNG, JPEG, or another format
PNG for text and transparency
PNG is lossless and supports transparent pixels, making it the safest default for UI cards, diagrams, and screenshots containing text.
Recommended Free Tools
const pngUrl = canvas.toDataURL("image/png");
JPEG for photographic content
JPEG creates smaller files for photographs but has lossy compression and no transparency. Supply a quality value from 0 to 1:
const jpegUrl = canvas.toDataURL("image/jpeg", 0.9);
const link = document.createElement("a");
link.download = "photo-card.jpg";
link.href = jpegUrl;
link.click();
WebP may be available in the browser, but format support and downstream compatibility should be checked before making it your only export.
Rank #4
- Dual 4x6" & 3x3" Photo Printer Paper Tray Convenience: Seamlessly print both 6-inch standard photo paper and 3-inch sticky-backed paper with our innovative dual tray design. This compact phone photo printer for smartphone offers easy storage and quick access, making it perfect for diverse printing needs without taking up much space. Enjoy vibrant, high-quality prints every time.
- Fast Bluetooth Connectivity: Experience lightning-fast printing with our liene photo printer's Bluetooth connection, which pairs in just 13 seconds. Enjoy a seamless and efficient printing experience, perfect for capturing and sharing memories on the go without the hassle of cables or complex setups.
- Superior Quality Photo Printer 4x6 - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Get Liene photo printers now as amazing gifts for yourself and your loved ones, print your happy moments together and keep your love forever!
- Multiple Device Compatibility - Liene picture printer for iphone provides instant photo printing for up to mutiple simultaneous connections. Share with family and friends or print from your different devices. No additional cables required when printing photos with this phone printer.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Polaroid border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this iphone photo printer for 4x6 & 3x3 prints.
Client-side rendering versus a real browser on a server
| Requirement | Client-side html2canvas | Server-side browser capture |
|---|---|---|
| Where rendering occurs | In the visitor’s browser | On infrastructure you operate or call |
| Pixel fidelity | Reconstructed from supported DOM and CSS properties | Can capture a real browser’s rendered page |
| External assets | Subject to browser origin and CORS rules | Controlled by the browser session and server network policy |
| Operational work | Bundle JavaScript and handle each visitor’s device | Run or pay for browser automation and manage timeouts, concurrency, and storage |
| Best fit | A user downloading the element currently displayed | Automated, repeatable, server-generated images or PDFs |
For server-side generation with a real browser, the html2canvas FAQ points to Puppeteer and Playwright as examples to investigate. Their deployment, fidelity, and cost depend on your page and infrastructure, so there is no universal winner established here.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. A single request can return a PNG, JPEG, WebP, or PDF from a URL. It is useful when the page must be rendered outside a visitor’s browser or captured repeatedly by a backend.
Its cleaning steps accept cookie or consent banners before capture and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
For a URL-based capture, use the documented API examples at ScreenshotNeo’s documentation:
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://stripe.com
-o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const bytes = new Uint8Array(await res.arrayBuffer());
// Write bytes to shot.webp with your runtime's file API.
ScreenshotNeo includes full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets and custom viewports, retina scale, PDF paper and page-range controls, custom CSS and JavaScript, pre-capture clicks, selector hiding, waits for selectors, delays or network idle, ad/tracker/request blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed public image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, an OpenAPI specification, and compatibility with parameter names used by other screenshot APIs.
Plans include 1,000 free shots per month with no card, Starter at $5 for 3,000, Growth at $15 for 15,000, Pro at $39 for 60,000, Scale at $99 for 250,000, and Business at $249 for 1,000,000. Yearly billing provides two months free, and every feature is available on every plan. Start with the free ScreenshotNeo account (1,000 screenshots monthly, no card).
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsTroubleshooting checklist
The downloaded file is blank
- Confirm the selector found the intended element and that it has non-zero dimensions.
- Wait for fonts, images, and asynchronous content before calling html2canvas.
- Inspect Console errors and Network failures, especially blocked image requests.
- Use
oncloneto remove an overlay that covers the target in the cloned document.
Images are missing or export throws a security error
The image is probably cross-origin without permission. Add the appropriate server CORS configuration or move the asset behind a same-origin proxy. useCORS: true helps only when the server permits the request.
Best Value
- Instant Photo Printing: The KODAK Mini 2 Retro is a portable photo printer designed to turn smartphone pictures into high quality prints in seconds. Whether capturing family moments, travel highlights, journaling pages, or creative projects, this mini printer lets you print real photos anytime, anywhere.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Mini 2 Retro is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Print Anytime, Anywhere: Small enough to fit in your hand, bag, or even a pocket, the Mini 2 Retro is built for on-the-go printing. Ideal for parties, trips, school projects, scrapbooks, and spontaneous moments where you want real prints without waiting.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
CSS looks different from the page
Check whether the styling uses a property html2canvas cannot reconstruct. Simplify the component for export, provide explicit dimensions and backgrounds, or use a real-browser server capture when exact rendered pixels are required.
The file is too large or the tab runs out of memory
Reduce the captured bounds or scale, avoid exporting unnecessarily large off-screen regions, and prefer JPEG for photographic content. Browser canvas limits vary by browser and device, so test your largest supported export rather than relying on one universal dimension.
The download does not start
Trigger the anchor click directly from the user’s button action, not from an unrelated delayed callback. Keep the anchor in the same document, set a valid filename, and verify that the browser allows downloads for the page.
Production checklist
- Define a stable target selector and explicit export dimensions.
- Wait for fonts, images, and data.
- Choose PNG, JPEG, or transparency deliberately.
- Set
scalefor the intended display or print density. - Mark controls and private UI with
data-html2canvas-ignore. - Verify every external image has usable CORS permission.
- Test the actual CSS in supported browsers.
- Handle Promise failures and give the user a recovery message.
- Move to a real-browser server workflow when automation, repeatability, or fidelity matters more than running in the visitor’s tab.
Frequently Asked Questions
Can html2canvas run in Node.js by itself?
No. It depends on browser APIs and is intended for modern evergreen browsers such as Chrome/Chromium, Firefox, and Safari. Use a real-browser server approach when generation must happen in Node.js.
Does setting useCORS make every remote image work?
No. The remote image server must allow your origin with suitable CORS headers, or the asset must be served through an appropriate proxy.
Can I capture an element without showing the download button?
Yes. Add data-html2canvas-ignore to the button, or hide it in the onclone callback so it is removed only from the cloned document used for rendering.
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.
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 →

