I'm trying to visualize a PDF that returns an API.
The code with which it worked so far is this:
$http.get(urlApi,{responseType:'arraybuffer'})
.success(function(data) {
var file = new Blob([data], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
});
Until now it worked correctly, but for a couple of days when the new tab opened, it closes instantly.
I have been doing tests and with the code:
window.open(fileURL, "_self");
It works correctly, the problem is that it obviously opens on the same tab, and it's not what I'm looking for, I need it to be in a new one.
Can you think of any idea of how to open the PDF in a new tab without it closing?