Capture the right thing first: use HTMLCanvasElement.toBlob() when you need only the pixels drawn by the canvas. Use html2canvas on a wrapper element when the image must include Angular layout, borders, backgrounds, labels, and other CSS. html2canvas reconstructs a picture from DOM and styles; it is not a native browser screenshot, so use an actual browser capture service when exact rendering of every CSS feature is required.
Decide what the image must contain
A canvas has two separate visual layers. Its drawing buffer contains paths, text, images, and pixels created through the Canvas API. The element around that buffer can have CSS width, height, borders, shadows, backgrounds, transforms, and neighboring Angular content. CSS presentation does not become part of the drawing buffer.
| Required output | Use | What you get |
|---|---|---|
| Only the chart or drawing | canvas.toBlob() or toDataURL() |
The origin-clean canvas bitmap, without CSS borders or surrounding DOM |
| A styled Angular component | html2canvas on the component or a wrapper | A client-side reconstruction of supported DOM and CSS |
| The exact browser-rendered result | Browser-native or automated-browser screenshot | Pixels produced by a real browser capture context; requires browser infrastructure |
Capture a parent element when the CSS frame matters. If a border or background must belong to a canvas-only export, draw those pixels into the canvas itself before exporting.
Prepare the Angular template and dimensions
Add references to the canvas and capture region
Give the canvas a template reference and wrap it with any labels or styling that should appear in the output.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
<section #captureRegion class="chart-card">
<h2>Revenue</h2>
<canvas #chartCanvas
width="1200"
height="675"
aria-label="Revenue chart"></canvas>
</section>
<button type="button" (click)="saveCapture()">Download PNG</button>
The width and height attributes set the intrinsic drawing dimensions. CSS can size the displayed element, but setting only CSS dimensions can stretch the bitmap and change its aspect ratio. If you change the intrinsic dimensions at runtime, redraw afterward because assigning canvas.width or canvas.height resets the rendering context.
Query after the view exists
Angular’s generated style attributes and component stylesheet must be present when the capture runs. Use a view query and wait until the view and your drawing code have completed.
import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
@Component({
selector: 'app-chart',
templateUrl: './chart.component.html',
styleUrls: ['./chart.component.css']
})
export class ChartComponent implements AfterViewInit {
@ViewChild('chartCanvas', { static: true })
private chartCanvas!: ElementRef<HTMLCanvasElement>;
@ViewChild('captureRegion', { static: true })
private captureRegion!: ElementRef<HTMLElement>;
ngAfterViewInit(): void {
this.drawChart();
}
private drawChart(): void {
const canvas = this.chartCanvas.nativeElement;
const context = canvas.getContext('2d');
if (!context) throw new Error('2D canvas context is unavailable');
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = '#1769aa';
context.fillRect(80, 100, 420, 220);
context.fillStyle = '#111827';
context.font = '32px sans-serif';
context.fillText('Revenue', 80, 70);
}
}
Capture the styled Angular region with html2canvas
Install and import
npm install html2canvas
Import it in the browser-side component. The library walks the live DOM and paints its own representation, so keep the target in the document with its stylesheets loaded.
import html2canvas from 'html2canvas';
Use a high-resolution, downloadable PNG
async saveCapture(): Promise<void> {
const element = this.captureRegion.nativeElement;
const output = await html2canvas(element, {
scale: window.devicePixelRatio,
backgroundColor: null,
useCORS: true,
});
output.toBlob((blob) => {
if (!blob) return;
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'angular-chart.png';
link.click();
URL.revokeObjectURL(url);
}, 'image/png');
}
scale controls output resolution; using the device pixel ratio generally produces a sharper result on high-density displays, but increases memory use. Set an explicit color such as '#ffffff' when the file must be opaque. backgroundColor: null preserves transparency where no DOM background is present.
Capture only the canvas bitmap
For a drawing-only file, bypass DOM reconstruction. This preserves exactly the pixels currently in the drawing buffer.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
downloadCanvasOnly(): void {
const canvas = this.chartCanvas.nativeElement;
canvas.toBlob((blob) => {
if (!blob) return;
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'chart-only.png';
link.click();
URL.revokeObjectURL(url);
}, 'image/png');
}
Use toDataURL('image/png') only when an inline data URL is specifically needed; Blob downloads avoid creating a potentially very large string.
Preserve CSS reliably
Keep the target rendered and styled
- Run capture after Angular has rendered the view and after asynchronous chart data, fonts, and images are ready.
- Capture the wrapper that owns the border, background, padding, and labels rather than the canvas child.
- Do not temporarily move the element to an unstyled document; Angular’s scoped style attributes and stylesheet cascade are part of the visual result.
- Hide controls with a capture-only class or html2canvas’s element filtering strategy rather than changing the production layout permanently.
Understand CSS support limits
html2canvas implements CSS properties manually. The project states that it will never have full CSS support, so test filters, masks, blend modes, advanced layout, generated content, and unusual transforms on the browsers your users run. A successful promise does not prove pixel parity with the browser viewport.
Choose output size deliberately
The rendered element’s dimensions and scale determine the output pixel dimensions. Very large regions or high scales can exceed browser canvas limits and produce blank or partial images. Reduce the capture area or scale when that happens, and verify dimensions on each target browser and device.
Remote images, fonts, and origin-clean security
Canvas export is subject to the browser’s same-origin rules. If a remote image is drawn without permission, the canvas becomes tainted and toBlob(), toDataURL(), or related reads can fail. html2canvas cannot bypass that policy.
- Serve images with an
Access-Control-Allow-Originresponse that permits your application origin (or an appropriate controlled value). - Set the image element’s
crossOriginproperty before assigning itssrc. - Use html2canvas’s
useCORS: trueoption for eligible remote images. - Check browser developer tools for blocked CORS responses, redirects, authentication failures, or expired signed URLs.
If the asset server cannot grant CORS permission, proxy the asset through your own origin (subject to licensing and security requirements), replace it with a same-origin copy, or omit it. A client-side option cannot make an unauthorized response readable.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
When a native browser screenshot is the better choice
Choose Playwright, Puppeteer, WebDriver, or a screenshot API backed by a real browser when exact support for CSS filters, masks, complex compositing, web fonts, responsive breakpoints, or browser-specific rendering is a hard requirement. Those methods capture the actual viewport rather than reconstructing it in JavaScript. They require a browser process, page-load synchronization, authentication handling, and infrastructure that html2canvas does not.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. It accepts a URL and returns PNG, JPEG, WebP, or PDF from a browser capture. For a deployed Angular route, one request can capture the rendered component without adding html2canvas to the app.
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 errorscurl -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 documentation for authentication and options. The same request in Python is:
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}`);
- Cookie banners, newsletter popups, and chat widgets are accepted or removed before the shot; each step can be disabled.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed as clean shots. Response headers identify the page verdict and billing status.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools to Claude, Cursor, and other MCP clients. - Options include full-page and element capture, device and retina settings, dark mode, custom CSS and JavaScript, waits, request blocking, headers, cookies, user agents, geolocation, timezone, PDF controls, caching, signed links, asynchronous jobs, bulk capture, and a usage API.
The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Troubleshooting checklist
The download is blank
- Confirm the canvas has been drawn before capture; call your capture method after the data and view are ready.
- Reduce the region or
scaleif the browser hit a canvas-size or memory limit. - Check whether a CSS transform, hidden ancestor, zero dimensions, or display state makes the target non-rendered.
The border or labels are missing
You captured the canvas instead of its wrapper. Pass the element containing the CSS border, background, and Angular markup to html2canvas.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Export throws a security error
Find the remote image or video that tainted the canvas, then provide CORS permission from that asset’s server or remove/proxy the resource. html2canvas’s CORS flags do not override browser policy.
Windows 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 reinstallOutdated 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 matchThe result differs from the page
That is expected for unsupported CSS or browser-only effects. Test the exact styles and switch to a real browser screenshot when fidelity is non-negotiable.
The image is blurry
Set intrinsic canvas dimensions for the intended drawing resolution and choose an appropriate scale. Avoid stretching a low-resolution canvas with CSS.
FAQ
Can CSS change the pixels returned by canvas.toBlob()?
No. CSS styles the element’s presentation; they are not part of its drawing buffer.
Should I use PNG or JPEG?
PNG is the safer default for charts, text, and transparency. Select another format only when your delivery requirements justify its compression and background behavior.
Recommended Free Tools
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Can html2canvas capture a canvas with remote images?
Only when those resources are permitted by CORS and the resulting canvas remains origin-clean. Otherwise export or rendering can fail.
Frequently Asked Questions
Does html2canvas take a literal screenshot?
No. It builds a new canvas from DOM and CSS information, so unsupported CSS can differ from the browser-rendered page.
How do I include a CSS border around a canvas?
Capture the parent or wrapper element that owns the border, rather than exporting the canvas element alone.
What resets a canvas drawing?
Assigning a new intrinsic width or height resets its rendering context; resize first, then redraw.
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 →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.

