Hey guys,
How can I get a PDF from a request and then open the PDF on the mobile phone?
I’m trying to receiving a PDF when I do this post, I turn the request to a blob and after to a url, the code works perfect on the browser, but not on the mobile.
let headers = new Headers();
...
let options = new RequestOptions({ headers: headers });
options.responseType = ResponseContentType.Blob;
let body = new URLSearchParams();
...
return new Promise( (resolve,reject) => {
this.http.post(URL, body, options)
.subscribe(res => {
let file = new Blob([res.blob()], { type: 'application/pdf' })
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
resolve(fileURL);
}),(err)=>{
reject(err)
}
});
}
``
I don't receive any errors.
The url on browser looks like this: blob:http://localhost:8100/63fda229-6078-4304-b586-cc600711e6c2
The url on mobile looks like this: blob:file%3A///46d7d7ba-64c8-44fc-9edf-72577773374a