2

I have a web application that uses AngularJS on the front-end, and WebAPI on the back-end.

I generate a PDF using built-in SQL Reporting Services functionality in the API, then convert it to a byte array to send back to the client. The final step is displaying the PDF to the user.

This is my AngularJS call to the API layer to get the byte array:

    this.$http({
        method: 'POST',
        url: getApiUrl()  //link to my API method
        cache: false,
        responseType: 'arraybuffer'
     }).then(function(response) {
        deferred.resolve(response);
    });

    return deferred.promise;

I am able to do this in Chrome with the following ("response" is what is returned from the above API call):

    var file = new Blob([response.data], {type: 'application/pdf'});
    var fileURL = URL.createObjectURL(file);
    this.$window.open(fileURL);

From Chrome, the PDF appears as expected and successfully within the browser in a separate tab.

However, in IE I am forced to use this, which brings up a prompt forcing the user to "open or save xxxx.pdf" before proceeding:

    this.$window.navigator.msSaveOrOpenBlob(file);

Our end-users have a requirement that the PDF needs to open directly from IE, without the extra step in the middle to "open or save." There are other libraries that allow you to do this if the PDF is saved to a directory and there is a link to the file, but I would like to dynamically generate it from the byte array and then display it without the middle step. Is there a way to achieve this in IE without (a) forcing the user to open or save, or (b) saving the file to a directory?

1

0

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.