If html2canvas rejects with a message such as Uncaught (in promise): [object undefined] while Angular 6 is exporting a view, first check whether the capture target contains an <iframe>. Excluding iframe elements fixed one reported case. It is not a universal explanation: the message identifies the type of the rejected value, not the underlying failure. Reproduce with a smaller target, inspect the rejected value, and test the iframe workaround before changing html2canvas internals.
What “[object undefined]” tells you
The message is an uncaught promise rejection surfaced through Angular’s Zone.js integration. The string [object Undefined] describes an undefined value: ECMAScript’s object-to-string behavior represents that value with this tag. It does not name the operation that failed, prove that Angular itself caused the failure, or identify a specific html2canvas bug.
In the reported export flow, code awaited html2canvas(header, { svgRendering: true }), converted the resulting canvas using toDataURL('image/png'), and passed the image to jsPDF. The failure appeared at the html2canvas call. Treat that sequence as a useful reproduction shape, not as proof that SVG rendering, canvas conversion, or jsPDF is always the cause.
Angular 6 and the reported workaround are legacy. Before copying a fix, note your installed html2canvas version, browser, and the element being captured. An option or behavior can differ across versions; verify it against the version in your application.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
Try excluding iframes from the capture
The most directly reported fix is to prevent html2canvas from processing iframe nodes. Use the ignoreElements callback in the capture options:
html2canvas(element, {
ignoreElements: (node) => node.nodeName === 'IFRAME'
}).then((canvas) => {
const image = canvas.toDataURL('image/png');
// Pass image to your existing jsPDF export code.
});
Here, element must be the actual DOM element you intend to capture. The callback excludes iframe elements from the rendered result; embedded content will therefore not appear in the resulting image. If a frame is essential to the output, this workaround is a trade-off rather than a complete fix.
Apply it to an Angular component
For example, if a component has a template reference on the section to capture, obtain its native element and pass that element to html2canvas. The following shows the capture step; keep your existing PDF setup and error handling:
Rank #2
import { ElementRef, ViewChild } from '@angular/core';
import html2canvas from 'html2canvas';
export class ReportComponent {
@ViewChild('report') report!: ElementRef;
exportImage(): void {
const target = this.report.nativeElement as HTMLElement;
html2canvas(target, {
ignoreElements: (node) => node.nodeName === 'IFRAME'
}).then((canvas) => {
const image = canvas.toDataURL('image/png');
// Add image to jsPDF here.
}).catch((error) => {
console.error('html2canvas capture failed:', error);
});
}
}
And in the template:
<section #report>
<!-- Content to capture -->
</section>
Angular and TypeScript configurations vary, so adjust the ViewChild declaration to match the TypeScript version and compiler settings in your Angular 6 project. The important diagnostic change is passing the intended element and excluding frames, not adopting a particular component style.
Check whether the frame is actually involved
- Capture a small element that does not contain an iframe. If it succeeds, add parts of the original target back until the failure returns.
- Temporarily remove or hide embedded frames in the original target and retry. If that changes the result, test
ignoreElementson the full target. - Check nested elements too: a frame may be inside a child component rather than visible in the component’s immediate template.
- Confirm the export still meets your needs. Excluding frames means their contents are not represented in the canvas image.
If the error persists with frames removed, do not keep treating the iframe hypothesis as established. Move on to the isolation and inspection steps below.
Try running the capture outside Angular’s zone
A separate reported integration workaround is to start the html2canvas call inside NgZone.runOutsideAngular(). This changes Angular zone scheduling for the capture flow; it is not a substitute for identifying a rejected value, and it is not guaranteed to resolve every DOM or browser failure.
Rank #3
import { NgZone } from '@angular/core';
import html2canvas from 'html2canvas';
export class CaptureComponent {
constructor(private ngZone: NgZone) {}
capture(target: HTMLElement): void {
this.ngZone.runOutsideAngular(() => {
html2canvas(target).then((canvas) => {
const link = document.createElement('a');
link.href = canvas.toDataURL('image/jpeg');
link.download = 'capture.jpg';
link.click();
}).catch((error) => {
console.error('html2canvas capture failed:', error);
});
});
}
}
This example follows the reported workaround’s image-download flow. If your application updates Angular-bound state after capture, re-enter Angular’s zone for that update, for example by injecting NgZone and calling this.ngZone.run(() => { ... }). If no Angular-managed state changes, there may be nothing to re-enter for.
How to interpret the result
- If excluding frames fixes the capture, keep the narrow exclusion if omitting frame content is acceptable.
- If running outside the zone changes the behavior but iframe exclusion does not, investigate the integration and scheduling context. Do not assume that this proves the zone was the sole cause.
- If neither changes the result, proceed with a minimal reproduction and inspect the rejected value rather than layering on both workarounds blindly.
Isolate the failure and inspect the rejection
Start with the smallest target that still reproduces the issue. Temporarily remove embedded frames and cross-origin content, then restore content in stages. This helps distinguish a problem in the target DOM from one in the surrounding export flow. A simplified capture should also omit unrelated jsPDF work: establish whether html2canvas resolves to a canvas before testing image encoding or PDF insertion.
Recommended Free Tools
Attach a rejection handler while debugging so the browser console shows the original error value available to your code:
Rank #4
html2canvas(target, {
ignoreElements: (node) => node.nodeName === 'IFRAME'
}).then((canvas) => {
console.log('Canvas created:', canvas.width, canvas.height);
}).catch((error) => {
console.error('Original html2canvas rejection:', error);
console.error('Rejection type:', typeof error);
console.error('Rejection value:', String(error));
});
The exact details available depend on what the library rejected. Preserve the original value in the console rather than relying only on the top-level Zone.js message. Compare a working and failing target, and record the browser and installed html2canvas version when narrowing the issue.
Keep the stages separate
- Capture: Does
html2canvas(target)resolve with a canvas? If not, focus on the DOM, capture options, frames, and rejection. - Encode: If a canvas is returned, does
canvas.toDataURL('image/png')complete? Test that independently of jsPDF. - Build the PDF: Only after image encoding works, pass the image to jsPDF and investigate PDF insertion separately.
The reported call included svgRendering: true, but that option should not be assumed to be necessary or supported in every html2canvas version. If it is present in your code, test a minimal capture without nonessential options and consult the documentation for the version you have installed.
Why not patch html2canvas internals first?
The report also mentions changing iframeLoader in Clone.js so it returns Promise.resolve(cloneIframeContainer). That is a library-internal change, not a general application-level fix, and the report warns it may break other use cases. It also couples your application to implementation details that can change between releases.
Free tools Windows power users keep installed
One-click scans. No signup required.
Prefer, in order, a small reproduction, an application-level exclusion if frames are the trigger, and a version-appropriate released fix if one exists. Consider a maintained fork or internal patch only when you control its testing and release process. If you do patch, document the exact library version and affected behavior, test other capture paths that use frames, and ensure the change is reapplied or deliberately retired when upgrading.
Troubleshooting by symptom
| What you observe | What to check | Next step |
|---|---|---|
| The capture succeeds after frames are removed | Whether an iframe exists anywhere inside the capture target | Try ignoreElements; accept that the frame content will be absent from the image. |
| The message remains after iframe exclusion | Whether the callback is applied to the intended target and whether other content changes the result | Reduce the target, remove cross-origin content temporarily, and inspect the rejection value. |
| The capture behavior changes outside Angular’s zone | How the capture is scheduled and whether the application expects Angular-bound state updates | Keep the workaround only if appropriate for the integration; re-enter the zone for Angular-managed updates. |
| A canvas is returned but export still fails | Whether failure occurs during toDataURL() or later in jsPDF |
Test encoding and PDF insertion as separate stages. |
| A suggested option or code sample does not compile | Installed html2canvas and TypeScript versions, imports, and compiler settings | Use documentation and typings for the installed package rather than assuming current examples match Angular 6. |
Or skip the browser setup
If your actual need is a screenshot of a publicly reachable page by URL—not a capture of an unsaved Angular component state followed by client-side jsPDF export—ScreenshotNeo offers a screenshot API. One GET request returns an image or PDF. Its cleanup behavior and billing outcomes are different from running html2canvas in your Angular app, so it is an alternative for URL-based captures, not a drop-in repair for this client-side code.
For example, save a WebP capture of a page you control 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 setup and options. ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents use screenshot tools, and the Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.
Frequently Asked Questions
Does the error mean Angular 6 is broken?
No. The message reports an undefined rejection surfaced through the promise and Zone.js stack; it does not by itself identify Angular as the cause.
Will excluding an iframe preserve what it displays?
No. The exclusion removes iframe elements from the captured output, so their embedded content will not be included.
Can ScreenshotNeo capture the current unsaved state of my Angular component?
The API example captures a page by URL; it is not a replacement for capturing arbitrary in-memory component state with html2canvas.
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.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →

