I\'m getting an InvalidStateError
at the blob creation line on IE 11. Needless to say, it works in Chrome and Firefox.
I can see that the binary data is my cli
Spent some time on this and actually found out adding new Uint8Array
works:
var blob = new Blob([new Uint8Array(request.response)], {type: 'application/pdf'});
After instantiating an XmlHttpRequest
with xhr.responseType = "blob"
I was getting an InvalidStateError
.
However, moving xhr.responseType = "blob"
to onloadstart
solved it for me! :)
xhr.onloadstart = function(ev) {
xhr.responseType = "blob";
}
Is not a elegant way but it works on IE8 - IE11:
var myForm = document.createElement("form");
myForm.method = "POST";
myForm.action = strURL;
myForm.target = "_blank";
var myInput = document.createElement("input");
myInput.type = "text";
myInput.name = "sim";
myInput.value = JSON.stringify(/*data to post goes here*/);
myForm.appendChild(myInput);
document.body.appendChild(myForm);
myForm.submit();
$(myForm).hide();
You need to use a BlobBuilder in that case.
From: https://github.com/bpampuch/pdfmake/issues/294#issuecomment-104029716
try {
blob = new Blob([result], { type: 'application/pdf' });
}
catch (e) {
// Old browser, need to use blob builder
window.BlobBuilder = window.BlobBuilder ||
window.WebKitBlobBuilder ||
window.MozBlobBuilder ||
window.MSBlobBuilder;
if (window.BlobBuilder) {
var bb = new BlobBuilder();
bb.append(result);
blob = bb.getBlob("application/pdf");
}
}