I have a requirement when the user clicks on the button I need to take a screenshot of that view and send back to the backend save it as pdf in DB and download the same. I am using DOM to Image angular package, Its able to take a screenshot and convert it to image and can be saved as to client system.
public takeScreenShot(){
domtoimage.toBlob(document.getElementById('my-node'))
.then(function (blob) {
window.saveAs(blob, 'my-node.png');
//I need to make a call to my service to send this blob object to backend.
});
}
I did try to call my service after saveAs but my service instance doesn't exist inside then
public takeScreenShot(){
let serviceObj= this.service;
domtoimage.toBlob(document.getElementById('my-node'))
.then(function (blob) {
window.saveAs(blob, 'my-node.png');
this.service.sendImage(blob).subscribe(res=>{//save as pdf to client system but this.service doesn't exist inside then.
//I did try to return blob and assign it, it doesn't work.
});
});
I need to call my service inside then not sure how can you please help me in this?
Thanks,