I have this method in TypeScript/Angular, that generate my file
imprimir() {
this.service.emitirAdvertencia({ parametros: [{ name: 'CODIGO', value: 880 }] })
.subscribe((response) => {
console.log(response);
var fileURL = window.URL.createObjectURL(response);
//this not display my pdf document in a new tab.
window.open(fileURL, '_blank');
//this display my document pdf, but in current tab
window.location.href = fileURL;
}, error => {
console.log(error);
});
}
This is my service
emitirAdvertencia(parametros: Object): any {
parametros['dbenv'] = ApplicationContext.getInstance().getDbenv();
parametros['usuario'] = ApplicationContext.getInstance().getUser().codigoUsuario;
parametros['nome_relatorio'] = 'RelAdvertenciaDB';
var httpOptions = {
headers: new HttpHeaders({
'Authorization': this.localStorage.get('token'),
}),
responseType: 'blob' as 'blob',
};
return this.http.get(ApplicationContext.URL + '/adiantamento/gerar-relatorio/', httpOptions)
.map((res) => {
var report = new Blob([res], { type: 'application/pdf' });
return report;
});
Like a commented in code, when i try open in a new tab, not works, only works if i open in current tab
How open this blob pdf file in new tab ?