O
O
odd-look2015-09-18 15:50:38
JavaScript
odd-look, 2015-09-18 15:50:38

How to download pdf in blob format via angularjs?

There is a PDF file in the form of a blob object, respectively, there is also a URL. Question: how to set a name and download it to the browser?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MrPanch, 2015-09-18
@odd-look

var myBlob = new Blob(["example"],{type:'application/pdf'})
var blobURL = (window.URL || window.webkitURL).createObjectURL(myBlob);
var anchor = document.createElement("a");
anchor.download = "myfile.pdf";
anchor.href = blobURL;
anchor.click();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question