1

I wanna get a screenshot of iframe, I use Angular 9.

enter image description here

component.html:

 <div>
   <img id='img' />
 </div>

<div>
     <iframe id="iframe" *ngIf="fileUrl" [src]="getFileUrl()"></iframe>
</div>

component.ts:

// take screenshot
var body = $('iframe').contents().find('body')[0];
      html2canvas(body).then((canvas: any) => {
        var base64encodedstring = canvas.toDataURL("image/jpeg", 1);
        $('#img').attr('src', base64encodedstring);
      });

0 Answers0