2

I have an issue at them moment, where in all browsers and platforms, I can convert a bse64 string to a PDF file using:

function runReport_onComplete(response)
{
    var element = document.createElement('a');
    element.setAttribute('href', encodeURI("data:application/pdf;base64," + response.Report));
    element.setAttribute('download', "LoginInquiry.pdf");
    element.style.display = 'none';
    document.body.appendChild(element);
    element.click();
    document.body.removeChild(element);
}

I have done some research, but I have not been able to find a solution where I can specify the file name, and have the file download automatically in Edge.

Thanks in advance for the help.

1
  • window.top.navigator.msSaveOrOpenBlob(blob, filename) Commented Nov 21, 2016 at 16:18

1 Answer 1

5

If I recall correctly, that is a general problem in IE and not just Edge. One can save named blobs in IE by using msSaveOrOpenBlob():

var tF = 'Whatever.pdf';
var tB = new Blob(..);

if(window.top.navigator.msSaveOrOpenBlob){
    //Store Blob in IE
    window.top.navigator.msSaveOrOpenBlob(tB, tF)
}
else{
    //Store Blob in others
    var tA = document.body.appendChild(document.createElement('a'));
    tA.href = URL.createObjectURL(tB);
    tA.download = tF;
    tA.style.display = 'none';
    tA.click();
    tA.parentNode.removeChild(tA)
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.