How to view pdf downloaded? There is no problem on downloading pdf, the problem is the viewing, cant view the downloaded pdf, why is that?
I have this code
static getAttachement(item) {
return axios.get(this.contextUrl + '/test', {responseType: 'blob'})
.then(response => {
console.log("response: ", response.data)
return response.data;
})
.catch(error => {
throw error;
});
}
this is the return
and this
const handlePrint = async () => {
await WorkflowApi.getAttachement().then((res)=>{
// Create blob link to download
const url = window.URL.createObjectURL(
new Blob([res]),
);
const link = document.createElement('a');
link.href = url;
link.setAttribute(
'download',
`FileName.pdf`,
);
// Append to html link element page
document.body.appendChild(link);
// Start download
link.click();
// Clean up and remove the link
link.parentNode.removeChild(link);
})
}
result