1

I'm using the new dom-to-image lib and I'm facing this error when I try to call the toPng method inside of a component.

import domtoimage from 'dom-to-image-more';
export class MyComponent {
    @ViewChild('leafletMap') leafletMap: ElementRef;
    
    downloadMap = (): void => {
        //error happens here
        domtoimage.toPng(this.leafletMap.nativeElement).then((img: any) => {
            console.log(img);
        });
    };
}
/* of course this is simplified */

The leafletMap exists in my components HTML and when I log it, it contains a HtmlNativeElement

tbarbot
  • 225
  • 1
  • 4
  • 18

1 Answers1

3

Seems there is an issue with the latest version of the lib. Try using this version:

"dom-to-image-more": "2.8.0"

I have created a working StackBlitz, click on download button and see the result.

Ritesh Waghela
  • 3,474
  • 2
  • 19
  • 25
  • 1
    Wow, it works. I guess I'll file an issue on their repo then. Thanks for the deep debugging ! – tbarbot Oct 12 '21 at 13:33