Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To render an Angular component as an image in the browser, select a real DOM element from its template, wait until Angular has rendered it, then pass it to html2canvas. The library returns a canvas you can display, download, or upload. This is a DOM-and-CSS reconstruction, not a pixel-perfect browser screenshot; for exact browser pixels or server-side capture, use a browser screenshot service instead.

Render a component after Angular has finished rendering

Install html2canvas in your Angular project with npm install html2canvas. In a standalone component, expose the part of the template to capture using a template reference variable, then query it with Angular’s viewChild. The example below captures after the initial browser render and creates a PNG data URL.

import { Component, ElementRef, afterNextRender, viewChild } from '@angular/core';
import html2canvas from 'html2canvas';

@Component({
  standalone: true,
  selector: 'app-card',
  template: `
    <section #captureRoot class="card">
      <h2>{{ title }}</h2>
      <p>{{ description }}</p>
    </section>
    <button type="button" (click)="capture()">Save image</button>
  `
})
export class CardComponent {
  title = 'A card';
  description = 'Rendered by Angular';
  private readonly captureRoot = viewChild.required<ElementRef<HTMLElement>>('captureRoot');

  constructor() {
    afterNextRender(() => {
      // The initial view is now rendered in the browser.
    });
  }

  async capture(): Promise<void> {
    const element = this.captureRoot().nativeElement;
    const canvas = await html2canvas(element, {
      windowWidth: element.scrollWidth,
      windowHeight: element.scrollHeight,
      backgroundColor: '#ffffff'
    });
    const pngDataUrl = canvas.toDataURL('image/png');
    // Use pngDataUrl to display, download, or upload the image.
    console.log(pngDataUrl);
  }
}

The import and template query require a browser-capable Angular application and a compatible html2canvas installation. Angular’s afterNextRender callback is a useful place for work that depends on a completed render; Angular cautions that arbitrary lifecycle-hook timing does not guarantee that the DOM is complete. For an interactive button, capture in the click handler after the view reflects the user’s action. If you change state and capture immediately in the same synchronous turn, let Angular render that change first, then capture from a subsequent render callback.

The element passed to html2canvas is the element whose contents should appear in the output, not the Angular component class or its TypeScript instance. ElementRef provides access to the native element selected from the template. Renderer2 helps with renderer-aware DOM operations; it does not rasterize a component into a bitmap.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Wacom Intuos Small, Wired Graphic Drawing Tablet with Pen + Software
  • Wacom Intuos Small Graphics Drawing Tablet: Enjoy industry leading tablet performance in superior control and precision with Wacom's EMR, battery free technology that feels like pen on paper
  • Works With All Software: Wacom Intuos tablet can be used in any software program to explore new facets of digital creativity; draw, paint, edit photos/videos, create designs, and mark up documents
  • What the Professionals Use: Wacom's industry leading pen technology and pen to paper feeling makes it the preferred drawing tablet of professional graphic designers
  • Software and Training Included: Only Wacom gives you software with every purchase. Register your Intuos tablet and gain access to some of the best creative software and Wacom's online training
  • Wacom is the Global Leader in Drawing Tablet and Displays: For over 40 years in pen display and tablet market, you can trust that Wacom to help you bring your vision, ideas and creativity to life

Turn the canvas into a downloadable file

For a simple download, create a temporary link from the canvas data URL:

const link = document.createElement('a');
link.download = 'card.png';
link.href = canvas.toDataURL('image/png');
link.click();

For larger output, prefer a Blob rather than keeping a base64 data URL in memory:

canvas.toBlob(blob => {
  if (!blob) return;
  const objectUrl = URL.createObjectURL(blob);
  const link = document.createElement('a');
  link.href = objectUrl;
  link.download = 'card.png';
  link.click();
  URL.revokeObjectURL(objectUrl);
}, 'image/png');

If you need JPEG or WebP, pass that MIME type to toBlob or toDataURL; browser support and encoding behavior apply. A transparent background is possible by setting html2canvas’s backgroundColor to null.

Capture on demand, after updates, or from a dynamic component

Capture after a user action

Calling html2canvas from a button handler is appropriate when the component is already rendered. Make sure any state updates that should appear in the image have been applied to the DOM before the call. If your handler changes state and then captures, schedule capture for a later Angular render callback rather than assuming the template has updated synchronously.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
UGEE M708 Drawing Tablet, 10x6 inch Large Space for Digital Drawing
  • Large Active Drawing Space: UGEE M708 V3 graphic drawing tablet features 10 x 6 inch large active drawing space with papery texture surface, provides enormous and smooth drawing for your digital artwork creation, offers no-lag sketch and painting experience
  • 16384 Passive Stylus Technology: A more affordable passive stylus technology offers 16384 levels of pressure sensitivity allows you to draw accurate lines of any weight and opacity according to the pressure you apply to the pen, sharper line with light pressure and thick line with hard pressure for artistry design or unique brush effect for photo retouching
  • Compatible with Multiple System and Softwares: Powerful compatibility, tablet for drawing computer, perform well with Windows 11/10/8/7, Mac OS X 10.10 or later, Android 10.0 or later, mac OS 10.12 or later, Chrome OS 88 or later and Linux; Driver program works with creative software such as Photoshop, Illustrator, Macromedia Flash, Comic Studio, SAI, Infinite Stratos, 3D MAX, Autodesk MAYA, Pixologic ZBrush and more
  • Ergonomically Designed Shortcuts: 8 customizable express keys on the side for short cuts like eraser, zoom in and out, scrolling and undo, provide a lot more for convenience and helps to improve the productivity and efficiency when creating with the drawing tablet
  • Easy Connectivity for Beginners: The UGEE M708 V3 offers USB to USB-C connectivity, plus adapters for USB C, ensuring easy connection to various devices and allowing beginner artists to set up quickly and focus on their creativity without compatibility concerns; Whether using a laptop, desktop, chromebook, or tablet, the UGEE M708 V3 provides a seamless experience for those just starting their digital art journey

Capture a dynamically created component

Angular can create dynamic components with NgComponentOutlet, ViewContainerRef, or the standalone createComponent API. The latter returns a ComponentRef and can receive an explicit host element. If creating a component outside the normal view hierarchy, attach its view to ApplicationRef, allow the browser render to complete, and pass the inserted host or a wrapper element to html2canvas. Keep a reference to that host so the capture targets the intended component rather than an unrelated container.

This approach can support an export-only instance, but the component still needs to be rendered in a browser DOM. It is not a way to render Angular templates on a Node.js server.

Know what html2canvas can and cannot capture

html2canvas traverses the DOM and reconstructs an image from the styles and properties it understands. It does not take a native screenshot of the browser’s pixels, so unsupported or partially supported CSS may look different from the screen. It works well for many cards, invoices, reports, and straightforward interface snapshots. Complex filters, blend modes, plugins, and browser-native surfaces may not reproduce faithfully. Third-party iframe contents are another boundary: a page cannot inspect a cross-origin iframe’s document to recursively render it.

If pixel fidelity matters, use a real browser screenshot rather than treating html2canvas output as an exact screenshot. A headless browser can render the Angular route and capture its pixels, but requires a browser environment and a page that has loaded. ScreenshotNeo offers a hosted screenshot API and MCP server at screenshotneo.com; its one-request capture is an alternative when you do not want to manage a browser yourself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
XPPen Deco 01 V3 10x6 Drawing Tablet, 16K Battery-Free Stylus, 8 Keys
  • Word-first 16K Pressure Levels: The upgraded stylus features 16,384 levels of pressure sensitivity and supports up to 60 degrees of tilt, delivering smoother lines and shading for a natural drawing experience. With no battery or charging needed, it operates like a real pen, making it easy for beginners to create effortlessly. This functionality helps novice artists develop their skills and explore their creativity without the intimidation of complex tools
  • Designed for Beginners: This drawing pad desinged with 8 customizable shortcuts for both right and left-hand users, express keys create a highly ergonomic and convenient work platform
  • Perfectly Adapted for Android: The XPPen Deco 01 V3 art tablet supports connections with Android devices running version 10.0 and above. It is recommended to download the XPPen Tools Android application, which adapts to your smartphone's screen aspect ratio, ensuring accurate mapping. It also supports mapping on Android screens with different aspect ratios in portrait mode
  • Large Drawing Space, Bigger Bold Inspiration: This expansive drawing pad has10 x 6.25-inch helps you break through the limit between shortcut keys and drawing area
  • Easy Connectivity for Beginners: The Deco 01 V3 offers USB-C to USB-C connectivity, plus adapters for USB C. This ensures easy connection to various devices, allowing beginner artists to set up quickly and focus on their creativity without compatibility concerns. Whether using a laptop, tablet, or desktop, the Deco 01 V3 provides a seamless experience, making it an ideal choice for those just starting their digital art journey

Wait for images, fonts, and other assets

A DOM render callback confirms Angular has rendered its view; it does not necessarily mean every external image, web font, or asynchronously loaded asset has settled. Capture too early and the output may use a fallback font, omit an image, or represent an intermediate layout.

  • Wait for the relevant image elements to finish loading before calling html2canvas.
  • Ensure web fonts are available before capture if typography affects layout.
  • For data-driven components, wait until the data and resulting view are present.
  • Use a fixed or known container size if late-loading content would shift the layout.

Handle cross-origin images and canvas security

Images from another origin can taint the canvas unless the image host permits access with a matching Access-Control-Allow-Origin response header. Setting useCORS: true asks html2canvas to attempt CORS loading; it does not override the image server’s policy. If you control the image host, configure its CORS response for your application. Otherwise, serve the resource through an appropriate same-origin proxy, subject to your security and licensing requirements.

When a canvas is tainted, browser APIs such as toDataURL or toBlob may fail with a security error. Do not assume that an image visible in the page is automatically exportable: the browser may display a cross-origin image while still restricting pixel access.

Fix cropping, blank output, and oversized captures

Content is clipped

For content extending beyond the element’s visible box, set the capture window dimensions from its scroll dimensions, as in the example. html2canvas documents windowWidth and windowHeight as a way to address clipping. Confirm that the chosen element actually contains the overflow content and that the page layout does not depend on a narrower viewport.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
HUION Inspiroy H1060P Graphics Drawing Tablet, 10 x 6.25 in, 12+16 Hot Keys
  • Working Area Configuration - HUION art tablet equips with a 10 x 6.25 inches working area, providing the user with the most comfortable size to work; the 10mm slim structure and minimalist design of appearance make the drawing tablet more attractive.
  • Tilt Function Battery-free Stylus: This computer graphics tablet come with a battery-free stylus PW100, no need to charge, allowing for constant uninterrupted drawing. ±60° tilt support enables imitation of lines input with diverse drawing gestures, with accuracy ensured.
  • Press Keys:12 programmable press keys plus 16 programmable soft keys, you can set shortcut keys on drawing tablet's driver based on your preferences, such as erase, zoom in/out, scroll up and down, and so on.
  • Compatibility: HUION graphics tablet supports Windows 7 or later/ macOS 10.12 or later/ Android 6.0 or later/ Linux (Ubuntu). A USB adapter is required to connect to a Mac computer. H1060P supports various mainstream design and drawing software, including PS, SAI, AI, CDR, etc. (Please note: The H1060P is compatible with Ubuntu, but it requires the use of the Xorg display server. Wayland is not supported.)
  • NOTE: You can easily connect your phone to the art tablet via the OTG connector; while iPhone and iPad are NOT at the moment. The cursor will not show up in the SAMSUNG Galaxy S series at present. If you are not sure whether the product is compatible with your Phone or any help, please contact us.

The result is blank or partial

Check that capture runs in a browser after the target element exists, that the element is not empty or hidden, and that required assets have loaded. A very large canvas can also exceed the browser or platform’s size limits. There is no single dependable maximum: limits vary by browser and hardware. Reduce the capture scale, split a long report into sections, or capture smaller regions instead of requesting one enormous bitmap.

Customize the cloned document, not the live view

html2canvas’s onclone option lets you change the cloned document used for rendering without changing the live Angular component. For example, hide an export button or apply capture-only styles in the clone. Other useful configuration options include backgroundColor, an existing canvas target, and cullOffscreen. Review the library’s configuration reference before relying on a particular option or CSS behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use browser-only code with Angular SSR and prerendering

html2canvas depends on browser globals such as window, document, and computed styles. It is a client-side library, not a Node.js or server-side renderer. Angular render callbacks do not run during server-side rendering or build-time prerendering, so do not expect an afterNextRender capture to create an image on the server.

Keep browser-dependent imports and calls out of server execution paths, and use the platform checks already used by your Angular application before invoking capture. When the application hydrates, capture only after the client has rendered the target. Angular recommends expressing structure through templates and bindings where possible; direct DOM operations should be limited to cases where they are needed, such as passing an existing element to a browser capture library.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
HUION Inspiroy H640P 6x4 inch Drawing Tablet 8192 Pen Pressure
  • Customize Your Workflow: The 6 customizable press keys on Huion H640P drawing tablet for pc let you assign your most-used commands—like undo, zoom, brush switch, or save—so you can keep your hands on the tablet and your mind on the art. Whether you're a digital painter switching brushes, or a comic artist zooming in and out, these keys keep your workflow smooth and uninterrupted. Plus, the Huion driver lets you save different shortcut profiles for different apps, so you never have to reconfigure when switching software.
  • Professional Pen Performance: Huion H640P drawing pad for computer comes with the battery-free PW100 stylus that's always ready when inspiration strikes. With 8192 levels of pressure sensitivity, every light sketch, or bold stroke responds naturally to your hand—just like a real pen. The 5080 LPI resolution and 233 PPS report rate deliver lag-free, precise strokes, so you can draw confidently without second-guessing your cursor. The pen side buttons help you switch between pen and eraser instantly.
  • Compact and Portable: Huion H640P computer graphics tablet features a compact, ultra-portable design at just 0.3 inches thin and 0.61 lbs light, so it slides easily into your backpack—perfect for sketching in coffee shops, taking notes in class, or editing on the go between home and studio. The 6x4 inch active area offers enough room for natural pen movements while fitting comfortably on crowded desks, or lecture hall seats.
  • Stable Compatibility: Huion H640P graphic drawing tablet works seamlessly with Mac, Windows, Linux PCs, and Android smartphones/tablets (OS version 6.0 or later). Left-handed friendly, and you just need to flip the tablet and adjust the settings in the driver. Please note: H640P does NOT support iPhone/iPad.
  • Move Beyond the Mouse: Huion Inspiroy H640P is a pen tablet that replaces your mouse for more natural, precise control. Freehand draw, take notes, or even play OSU—everything you do with a mouse, you can do better with a pen. The precise tip makes it ideal for detailed photo editing, graphic design, or signing PDF. Meanwhile, the ergonomic pen grip helps you avoid the strain that comes from hours of using a mouse.

Or skip the browser setup

For a rendered public URL, ScreenshotNeo returns an image or PDF from one GET request. See the ScreenshotNeo API documentation for parameters and output options.

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}`);

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with response headers indicating the page verdict and billing status. An MCP server provides screenshot tools for AI agents, and the 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.

Frequently Asked Questions

Can html2canvas capture an Angular component on the server?

No. It requires browser DOM APIs and is intended for client-side use. For a server-generated capture, use a headless browser or hosted screenshot service.

Why does the canvas look different from the page?

html2canvas reconstructs the image from DOM and CSS it supports rather than sampling the browser’s actual pixels. Unsupported styles, cross-origin content, and assets that have not loaded can change the result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I make the background transparent?

Yes. Set html2canvas’s backgroundColor option to null, provided the content itself does not paint an opaque background.

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.