Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var downloadLink = document.createElement('a');
- downloadLink.target = '_blank';
- downloadLink.download = 'name_to_give_saved_file.pdf';
- // convert downloaded data to a Blob
- var blob = new Blob(['downloadedFile'], { type: 'application/pdf' });
- // create an object URL from the Blob
- var URL = window.URL || window.webkitURL;
- var downloadUrl = URL.createObjectURL(blob);
- // set object URL as the anchor's href
- downloadLink.href = downloadUrl;
- // append the anchor to document body
- document.body.append(downloadLink);
- // fire a click event on the anchor
- downloadLink.click();
Add Comment
Please, Sign In to add comment