What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The reliable Angular fix is to use the maintained @html2canvas/html2canvas package, call it only after the view exists in a browser, and treat cross-origin assets and canvas-size limits as separate problems. Import the default export, capture a real element through ViewChild, enable CORS only when the asset server sends permission, and size large captures from the element’s scroll dimensions. The complete pattern below also covers Angular SSR, missing images, tainted canvases, blank output, clipped reports, unsupported CSS, and TypeScript signature errors.
Install the package and make the first capture
Install the package documented by the project:
npm install @html2canvas/html2canvas
Use a template reference (or ViewChild) and invoke html2canvas after Angular has created the view. The following component downloads a white-background PNG and includes diagnostics useful while fixing failures.
import { Component, ElementRef, ViewChild } from '@angular/core';
import html2canvas from '@html2canvas/html2canvas';
@Component({
selector: 'app-report',
template: `
<section #capture class="report">
<h1>Monthly report</h1>
<img src="https://cdn.example.com/chart.png" alt="Chart">
<p>Report content…</p>
</section>
<button type="button" (click)="savePng()">Download PNG</button>
`
})
export class ReportComponent {
@ViewChild('capture', { static: false }) capture!: ElementRef<HTMLElement>;
async savePng(): Promise<void> {
const element = this.capture.nativeElement;
const canvas = await html2canvas(element, {
backgroundColor: '#ffffff',
useCORS: true,
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
logging: true,
onError: error => console.warn('html2canvas resource failed:', error.message),
});
const link = document.createElement('a');
link.download = 'report.png';
link.href = canvas.toDataURL('image/png');
link.click();
}
}
The current guide uses this default import and Promise-based call pattern. A browser event such as a button click is a safe point to run it; do not call it while the component is being constructed, before the target is attached, or while its content is still loading.
Angular lifecycle, TypeScript, and SSR fixes
Capture only an existing browser element
With static: false, ViewChild is available after the view has been initialized. If the target is behind an *ngIf, wait until that condition renders it (and, when necessary, until images or charts finish loading) before calling the method. Confirm capture is not undefined and that the element has non-zero dimensions.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Resolve “lacks a call signature”
That Angular/TypeScript error was reported with older release candidates when an import was treated as a module object. Check the installed package version and use:
import html2canvas from '@html2canvas/html2canvas';
Review TypeScript module-interop settings if the compiler still rejects the default import. Do not change capture options until the import itself compiles.
Keep html2canvas out of server rendering
html2canvas depends on window, document, and computed styles. It is not a Node.js or server-side renderer. In Angular Universal, defer the import and call to a browser-only path (for example, check browser execution and run from a user action). A server build must not execute the library while rendering HTML.
Missing images and “tainted canvas” errors
What useCORS can and cannot do
Inspect each image and CSS background request in browser developer tools. Keep useCORS: true only when the response from the image server includes an appropriate Access-Control-Allow-Origin header. Angular code cannot override the browser’s content policy; the html2canvas FAQ states that it cannot circumvent those restrictions.
Rank #2
If you control the asset server, configure CORS for the application’s origin (or an intentionally permitted origin). Otherwise, fetch the asset through a controlled same-origin proxy that returns the image with suitable headers, or pre-embed it as a same-origin/data asset. Account for the proxy’s latency, authentication, caching, and security implications.
Do not confuse allowTaint with read access
allowTaint: true permits drawing an image that taints the canvas; it does not make toDataURL(), getImageData(), or similar readback safe. If your goal is a downloadable PNG, solve CORS or proxy the asset instead.
Check redirects and final URLs
An apparently same-origin image can redirect to a CDN. Issue #3020 documents how that redirect can prevent CORS handling from being enabled early enough. Test the final URL in the Network panel, then use that CDN URL directly, configure the redirect target with CORS headers, or route it through your controlled proxy.
Blank, clipped, or low-resolution captures
Use the element’s full scroll size
For a report taller or wider than its viewport, pass its scroll dimensions. Browser canvas limits vary by browser and device; when the total area is too large, browsers may silently return a blank or partially rendered canvas.
Rank #3
const canvas = await html2canvas(element, {
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
scale: Math.min(window.devicePixelRatio, 2),
});
Reduce the render when limits are reached
- Capture long reports in sections and combine or paginate them.
- Lower
scale; device-pixel-ratio values above 2 often multiply memory use without improving a practical export. - Remove unnecessary shadows, huge background images, and off-screen content from the capture.
- Test on the browsers and devices your users actually run; there is no universal maximum dimension.
If an image is blank but the document is otherwise correct, return to the CORS checks rather than repeatedly increasing dimensions.
Understand what html2canvas can render
html2canvas reconstructs the DOM; it does not copy the browser’s final pixels. Unsupported CSS properties can disappear, plugin content is not rendered, cross-origin iframe contents are inaccessible, and a child canvas already tainted by cross-origin content remains unreadable.
Exclude or replace troublesome nodes
Mark an element with data-html2canvas-ignore, or use an ignoreElements predicate:
const canvas = await html2canvas(element, {
ignoreElements: node => node.matches?.('.video-player, .live-controls') ?? false,
onclone: clonedDocument => {
const widget = clonedDocument.querySelector('.live-widget');
widget?.replaceChildren(Object.assign(clonedDocument.createElement('span'), {
textContent: 'Widget omitted from export'
}));
}
});
onclone edits only the cloned document, so a live Angular view is not changed. It is useful for replacing a dynamic chart, video, chat panel, or control with a static placeholder. foreignObjectRendering is an optional, browser-dependent mode—not a universal CSS compatibility switch—so compare it only on browsers that support it.
Rank #4
A repeatable debugging sequence
- Target: verify the element is attached, visible, and has the expected
scrollWidthandscrollHeightwhen the method runs. - Build: confirm the package version and default import compile without a module-object error.
- Diagnostics: enable
logging: trueand addonError; inspect the console for failed resources. - Assets: inspect every
<img>, CSS background, SVG, and nested canvas in Network tools, including redirects. - CORS: test
useCORS: trueand verify the final response’s headers. If permission is absent, configure the server or use a controlled proxy. - Dimensions: match
windowWidth/windowHeightto scroll dimensions, then lowerscaleor split the document. - Content: exclude unsupported nodes and try
foreignObjectRenderingonly as a browser-specific comparison. - Runtime: in SSR, confirm no import or call occurs on the server.
Choose the right workaround
| Situation | Preferred approach | Trade-off |
|---|---|---|
| You control the image server | Add correct CORS headers and retain useCORS |
Requires server configuration and correct handling after redirects |
| You do not control the asset host | Use a controlled same-origin proxy or data embedding | Adds latency and proxy security/maintenance responsibility |
| Unsupported CSS or iframe content is essential | Change the export representation or use a different capture approach | May require a dedicated rendering service or redesigned markup |
| Very large report | Paginate/split captures and manage scale |
Multiple files or an assembly step |
| Angular Universal/SSR | Defer all browser-only work | No server-side html2canvas output |
Or skip the browser setup
If you need a clean website screenshot rather than a canvas reconstructed inside your Angular page, ScreenshotNeo makes one GET request and returns PNG, JPEG, WebP, or PDF. Its capture flow accepts cookie/consent banners before removing more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
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 documentation for all 63 options, including full-page lazy-image loading, CSS-selector element capture, device presets and custom viewports, retina scale, PDF paper and page ranges, custom CSS/JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen TTL caching, signed links, async webhooks, bulk capture (100 URLs per call), usage API, and OpenAPI compatibility.
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}`);
The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free ScreenshotNeo plan.
FAQ
Can html2canvas capture an entire cross-origin iframe?
No. Browser isolation prevents access to another origin’s iframe document; capture content you control or use a service that renders the page independently.
Why does a successful canvas still fail at toDataURL()?
A cross-origin image or nested canvas probably tainted it. Drawing succeeded, but readback remains prohibited until every asset is CORS-authorized or proxied.
Should I always enable foreignObjectRendering?
No. It is browser-dependent and can introduce its own compatibility differences. Use it only after checking the target browsers and comparing the output.
Is html2canvas suitable for a Node.js screenshot job?
No. It requires browser globals and computed styles. Use a browser-capable rendering service or automation stack for server-side jobs.
Frequently Asked Questions
Can html2canvas capture an entire cross-origin iframe?
No. Browser isolation prevents access to another origin’s iframe document; capture content you control or use a service that renders the page independently.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Why does a successful canvas still fail at toDataURL()?
A cross-origin image or nested canvas probably tainted it. Drawing succeeded, but readback remains prohibited until every asset is CORS-authorized or proxied.
Should I always enable foreignObjectRendering?
No. It is browser-dependent and can introduce compatibility differences. Use it only after checking target browsers and comparing output.
Is html2canvas suitable for a Node.js screenshot job?
No. It requires browser globals and computed styles. Use a browser-capable rendering service or automation stack for server-side jobs.
The Bottom Line
Fix html2canvas systematically: run it only in the browser after Angular renders the target, use the maintained default import, authorize or proxy every cross-origin asset, size large captures from scroll dimensions, and exclude content the DOM renderer cannot reproduce. For an independent website capture without browser setup, ScreenshotNeo is the direct alternative.
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 problemsQuick 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.




