The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →To let someone download an image of an HTML element styled with CSS, render that element with html2canvas, convert the resulting canvas to a PNG data URL, and trigger a download with a temporary link. This is a client-side method: it runs in a browser, and the result is a DOM-based reconstruction—not a pixel-for-pixel screenshot of the browser. If you need a real-browser capture on a server, use browser automation or a screenshot service instead.
Make an HTML element downloadable as a PNG
The workflow is: select the element, render it to a canvas, convert the canvas to an image URL, and click a link with a download filename. The example below captures a card when the user presses a button.
Load html2canvas in your page using your project’s usual package or script-loading method before running this code. The library requires browser APIs; it is not suitable for Node.js by itself.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Download a card as an image</title>
<style>
body { font: 16px system-ui, sans-serif; padding: 2rem; }
#card {
width: 360px;
padding: 2rem;
color: #152238;
background: #eef4ff;
border: 1px solid #b8c9e8;
border-radius: 16px;
}
#card h1 { margin-top: 0; }
</style>
</head>
<body>
<section id="card">
<h1>A downloadable card</h1>
<p>This HTML content will be rendered to a PNG.</p>
</section>
<button id="download" type="button">Download PNG</button>
<p id="status" role="status"></p>
<script>
const button = document.querySelector('#download');
const status = document.querySelector('#status');
button.addEventListener('click', async () => {
const element = document.querySelector('#card');
if (!element) {
status.textContent = 'The element to capture was not found.';
return;
}
button.disabled = true;
status.textContent = 'Preparing image…';
try {
const canvas = await html2canvas(element, {
backgroundColor: null,
scale: window.devicePixelRatio || 1,
useCORS: true
});
const link = document.createElement('a');
link.download = 'card.png';
link.href = canvas.toDataURL('image/png');
link.click();
status.textContent = 'Your PNG download should begin.';
} catch (error) {
console.error('Image capture failed:', error);
status.textContent = 'Could not create the image. Check the console and try again.';
} finally {
button.disabled = false;
}
});
</script>
</body>
</html>
The sample uses a transparent canvas background, device pixel ratio for output scale, and useCORS to request permitted cross-origin images. Remove or change those settings if they do not suit your desired output; none of them grants access to a resource whose server denies it.
Outdated 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 matchWindows 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#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.
Choose the capture target
Pass the specific element you want, such as document.querySelector('#card'), rather than the whole document. Check that the selector returns an element before invoking the renderer. If the element is populated asynchronously, wait until its content is ready before capturing. The capture should happen only after required fonts, images, and other content have loaded; a screenshot taken too early can omit late-arriving content.
Choose the output and filename
The example calls canvas.toDataURL('image/png') and sets link.download to card.png. To produce another supported canvas image format, change the MIME type and file extension together, for example to image/jpeg and card.jpg. PNG is a sensible default when transparency matters. JPEG does not preserve transparency, so select an explicit background color for it rather than relying on a transparent canvas.
What html2canvas does—and what it cannot promise
html2canvas does not take a literal screenshot of the browser’s rendered pixels. Its documentation describes a process that reads DOM properties and builds a representation of the page. As a result, CSS features it does not understand may be missing or rendered differently. Treat the output as a generated rendering and compare it with the page in your target browsers, especially if the design depends on complex styling.
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.
This distinction matters when the image must match the live page exactly. A DOM renderer can be convenient for letting a visitor export a component from the page they already have open. If exact browser output or server-side generation is essential, investigate a real-browser approach such as Puppeteer or Playwright; the available evidence does not establish one as universally better, nor compare their deployment needs or costs.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Adjust bounds, scale, background, and exclusions
Capture a region or a full element
Rendering a selected element naturally limits the capture to that element. The library’s examples also describe passing coordinates and dimensions to capture a region. Use region bounds when you need a portion of a larger target, and verify the resulting canvas dimensions and crop in the actual output rather than assuming the visible viewport and capture bounds are interchangeable.
Set scale for sharper output
The scale option controls the rendered canvas scale. A larger scale can provide more pixels for high-density displays or print layouts, but it also increases the amount of canvas data to render and encode. The sample uses the browser’s devicePixelRatio as a starting point. Check image dimensions, file size, and memory use for your real element and browser; no single scale is right for every use case.
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.
Set a background or transparency
Use backgroundColor to control the canvas background. Set it to a color when the exported image needs a predictable backdrop. Set it to null when transparency is desired and the output format supports it. Inspect the saved file in an image viewer because a transparent background can appear white or black in some preview contexts.
Exclude controls and modify the cloned page
Add data-html2canvas-ignore to elements that should not appear in the exported image, such as a control that sits inside the capture target. The configuration also provides onclone, which lets you modify the cloned document used for rendering—for example, to apply capture-only styles without changing the live page. foreignObjectRendering is another documented configuration option. These controls can help adapt a capture, but they do not guarantee that every CSS property will render identically.
Handle cross-origin images and other assets
Images loaded from another origin are subject to browser canvas security rules. The remote server must permit cross-origin access with suitable CORS headers, or the resource must be served through an appropriate same-origin proxy. Without that permission, the browser may prevent the canvas from being safely read or exported.
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.
useCORS: true asks the renderer to use CORS for eligible image requests; it does not bypass origin policy or make a remote server grant permission. If the image server does not allow access, the practical choices are to change the asset’s hosting or permissions, use a proxy you are authorized to operate, or omit that asset from the capture. Do not assume that an image visible in the page can automatically be included in an exportable canvas.
Troubleshoot a missing, blank, or incorrect image
- The button does nothing: confirm html2canvas has loaded before the click handler runs, the selector identifies the intended element, and the browser console has no script error.
- The output is blank or incomplete: ensure the target has rendered and its content is ready before capture. Check whether styles or elements are unsupported by the renderer, and test a simpler target to isolate the problem.
- An external image disappears or export fails: check the image server’s CORS response. Enabling
useCORSis not a workaround for missing permission; use authorized same-origin hosting or a suitable proxy. - The design differs from the live page: remember that html2canvas reconstructs a rendering from DOM properties. Check the CSS features used by the component, then consider a real-browser screenshot route if pixel-level browser output is required.
- The file looks soft: review the
scalesetting and the final canvas dimensions. Raising scale increases resolution as well as rendering and encoding work. - The background is unexpected: choose an explicit
backgroundColor, or usenullwhen transparency is wanted and supported by the selected output format. - The download has the wrong format or name: align
link.downloadwith the MIME type passed totoDataURL. Confirm that the browser begins the download after the user’s button click.
Performance, reliability, and cost considerations
Client-side rendering avoids setting up a server-side browser for this workflow, but the user’s browser must do the rendering and image encoding. Large targets, high scale values, and image-heavy content require more work than a small card. Keep the capture area limited to what the user needs, avoid capturing before resources are ready, and test on the browsers and devices your audience actually uses.
There is no universal canvas size or performance threshold established here. Browser capabilities and page content affect the result, so measure with your own layout rather than promising a fixed maximum or completion time. For server-side browser automation, account for the work of deploying and operating a browser runtime; compare that against your application’s fidelity, volume, and operational requirements.
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.
Or skip the browser setup
If you need a screenshot generated from a URL rather than an in-page export of a selected DOM element, ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. A single GET request can return an image or PDF. Its clean-shot flow accepts consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with the response identifying the page verdict and billing status in headers. AI agents can use its MCP tools, including take_screenshot, get_page_info, and capture_pdf.
For example, save a webpage capture as WebP with cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. The API can also return PNG, JPEG, or PDF; it includes options such as full-page capture, CSS-selector element capture, custom CSS and JavaScript, viewport and device settings, waiting conditions, and image resizing. The right choice depends on whether you need an in-page component export or a URL-based capture: html2canvas renders a selected DOM element in the visitor’s browser, while the API is a URL screenshot service.
ScreenshotNeo’s Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.
FAQ
Can html2canvas run in Node.js?
No. It relies on browser APIs. For server-side browser rendering, investigate Puppeteer or Playwright instead.
Does html2canvas capture everything exactly as Chrome displays it?
No. It reconstructs a representation from DOM properties, so unsupported CSS can differ or be absent.
Does useCORS let me export any image on the web?
No. The image’s server must permit cross-origin access, or you need an authorized proxy or a different asset source.