For those that run into this issue later on. Dinesh Rajput's answer used to work, but msSaveOrOpenBlob()
is now deprecated and should only be used on older versions of IE and Legacy versions of Edge. Now you can just set the iframe src to your pdf.
I know this is old, but I have been stuck on this for a while and I figured it out.
The issue is that Edge has a char limit for URIs. You have to turn your pdf into a blob first.
//Convert to blob
var byteCharacters = atob(response);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
var blob = new Blob([byteArray], { type: 'application/pdf' });
//Convert blob into URL Object
blob = window.URL.createObjectURL(blob);
//Set URL Object as iFrame src
document.getElementById('iframe').src = blob;
This should actually work for all modern browsers, so no need for browser/feature check.