I am using this library but upon calling the "toBlob" method I get an error saying "domtoimage" is undefined.
I have imported it using
npm install dom-to-image
and then
import domtoimage from 'dom-to-image';
Usage:
domtoimage.toBlob(this.posterFinal.nativeElement)
.then((blob) => {
filesaver.saveAs(blob, 'Student-Talks-poster.png');
});
One note: I am calling it from within a setTimeout() which might affect some things? I am not sure. However, the exact same code works on my Mac with Chrome.
Download the blob as an png.
Doesn't download because of this error:
core.es5.js:1020 ERROR TypeError: Cannot read property 'toBlob' of undefined
at eval (graphics-builder.component.ts:163)
at ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.es5.js:3881)
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:192)
at ZoneTask.invokeTask (zone.js:499)
at ZoneTask.invoke (zone.js:488)
at timer (zone.js:2040)
Wait I got it to work!
Changed this:
import domtoimage from 'dom-to-image';
To this:
import * as domtoimage from 'dom-to-image';
Most helpful comment
Wait I got it to work!
Changed this:
To this: