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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

If this error appears while calling domtoimage.toPng(...) in Angular 12, first check the installed dom-to-image-more version and the exact DOM node passed to the library. A 2021 report of this same error was resolved by its accepted answer’s suggestion to pin the package to 2.8.0, but that is a historical, case-specific workaround—not a verified current best version or a guaranteed fix. Also confirm the conversion runs in a browser, because dom-to-image-more depends on document and browser rendering.

The minified name c alone does not identify the cause. Work through the checks below at the call site where the error occurs.

What the error means

getComputedStyle is a browser API on window. It returns the resolved CSS styles for an element, after the browser has applied stylesheets and other computations. Its argument must be an Element. A caller may see a TypeError if it supplies an invalid argument; in a minified stack trace, however, the local variable name c does not tell you what value it represents.

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

dom-to-image-more reads computed styles as part of rendering a DOM node into an image. The error can therefore surface inside the library even though your code only calls toPng. The exact Angular 12 report involved a Leaflet map element accessed through @ViewChild and passed to domtoimage.toPng(this.leafletMap.nativeElement). Its author said the element existed and logged as a native HTML element. That makes it important not to assume every occurrence is simply a missing or invalid Angular reference.

Check the installed package version first

In the matching Stack Overflow report, published on 2021-10-12, the accepted answer attributed the problem to an issue with the latest library version and recommended [email protected]. Treat this as a lead to test against your own dependency history, not as proof that 2.8.0 is the right version for every Angular 12 app or that it is the current latest release.

  1. Inspect the version actually installed in the project, not just the version range in package.json. Check the lockfile as well; it records the resolved dependency version used by the install.
  2. Compare that version with the last working build. If the error began after a dependency update, identify whether dom-to-image-more changed directly or was resolved differently after a reinstall.
  3. If the installed version matches the timeframe of the reported regression, test the reported 2.8.0 version in a branch or clean reproduction. Verify the result with your Angular build and browser rather than assuming the historical workaround applies unchanged.
  4. Keep the tested version and lockfile together when validating the fix. A version constraint alone may resolve to a different release later.

Do not downgrade blindly in production: confirm compatibility with the rest of the application and that the same capture works under the browsers and build configuration you support. The available report does not establish a current recommended release or a broader compatibility matrix.

Verify the exact element at the conversion boundary

Angular’s @ViewChild reference is only useful after the view has been initialized. Log the value immediately before the conversion, not earlier in the component lifecycle or from a different event handler. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const node = this.leafletMap?.nativeElement;
console.log('capture node:', node);
console.log('is Element:', node instanceof Element);

if (!(node instanceof Element)) {
  throw new Error('Expected a rendered DOM Element before calling toPng');
}

domtoimage.toPng(node)
  .then((dataUrl) => {
    // Use the generated data URL.
  })
  .catch((error) => {
    console.error('DOM-to-image conversion failed:', error);
  });

This is a diagnostic guard, not a workaround for a library regression. If it passes, you have evidence that the object at your call site is an Element; it does not prove that the library version or its internal handling is correct. If it fails, check that the selector or @ViewChild points to the intended rendered element and that the call happens after Angular has created the view.

Check the template reference and lifecycle

For a view query, confirm the template contains the matching reference and that your code does not run before the view is ready. A typical shape is:

// Template
<div #leafletMap></div>

// Component
@ViewChild('leafletMap') leafletMap!: ElementRef<HTMLElement>;

Place the call in a user action or a lifecycle point at which the view exists, and still inspect this.leafletMap?.nativeElement at the moment of capture. The error’s wording does not establish that Angular itself is at fault; Angular is one way the element is obtained, while the failing operation may be inside the image-conversion dependency.

Make sure conversion runs in the browser

The dom-to-image-more README describes a browser-side rendering process that reads computed styles. It cannot run in an environment where document is unavailable, including Angular Universal server rendering and plain Node.js. If the capture path can execute during server-side rendering, defer it until browser execution. This is a documented library constraint, but it is not evidence that server rendering caused the 2021 Angular report.

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

Check the environment at the same boundary as the conversion. Avoid invoking capture from code that runs during server rendering; invoke it from a browser-only interaction or a browser-only code path instead. If your application supports both server and browser rendering, test both paths so a client-side fix does not leave a server-side call behind.

Use the stack trace to isolate the failing layer

When the stack trace points into a minified bundle, find the first frame belonging to your application and the dependency frames immediately below it. Source maps, when available in your development build, can make this easier. Then reduce the problem to one element and one conversion call, removing unrelated map setup or page interactions where possible.

  • The Element guard fails: investigate the template reference, lifecycle timing, or the object being passed.
  • The guard passes, but the same library call fails: compare the installed dependency version with the last working version and test the reported historical version in isolation.
  • The call runs where document is unavailable: move it to a browser-only path.
  • A small browser-only reproduction still fails: preserve the exact installed version, stack trace, input node type, and steps to reproduce. Those details are needed to distinguish a package defect from an application-specific issue.

The original report linked a StackBlitz reproduction, but its present accessibility and behavior have not been established here. Do not rely on that reproduction as a current compatibility test.

Common causes and fixes

What you observe What to check Next step
The failure began after a dependency update Resolved package version in the lockfile and the last working install Test a controlled version change, including the reported 2.8.0 workaround if relevant; verify rather than treating it as universal.
The input is missing or not an Element The exact value passed to toPng at call time Correct the reference or timing, and guard the call until an Element is available.
Capture runs during server rendering Whether document exists in the execution context Run the conversion only in the browser.
The error remains after these checks First application stack frame, source maps, dependency version, and a minimal reproduction Isolate the failing boundary before changing unrelated Angular or Leaflet code.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What a fix should and should not change

A successful dependency fix should make the same intended element convert successfully in the affected browser environment, with the application’s real styles and content. Validate the output visually and check that the capture path still behaves as expected after a clean install from the lockfile.

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

Do not infer from this error that every screenshot or PDF workflow needs a different library. If your requirement is specifically to rasterize a live Angular DOM element, a remote screenshot service is not a drop-in repair for that client-side conversion: it captures a URL rather than accepting this component’s in-memory DOM node. If your actual need is a screenshot of a publicly reachable page, a hosted capture API may avoid setting up the rendering browser yourself.

Or skip the browser setup

For a URL-based capture rather than conversion of an in-memory Angular element, ScreenshotNeo provides a screenshot API and MCP server. One GET request can return a screenshot or PDF; the example below captures a URL as WebP. The [API documentation](https://screenshotneo.com/docs/) describes the request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. These are service features and do not replace a fix when you need to convert a particular Angular component’s DOM node.

Sign up for 1,000 free screenshots a month with no card.

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

Frequently Asked Questions

Does Angular 12 itself cause this error?

The matching report involved an Angular 12 component, but the accepted answer pointed to a `dom-to-image-more` version issue. The error text alone does not establish Angular as the cause.

Will pinning `dom-to-image-more` to 2.8.0 always fix it?

No. That version was a historical workaround accepted for one 2021 report. Test it against your installed dependency history, application, and browser.

Can ScreenshotNeo capture an Angular component that exists only in memory?

No. The API captures a URL; it is not a replacement for passing an in-memory DOM element to `dom-to-image-more`.

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.

Free tools Windows power users keep installed

One-click scans. No signup required.

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