const download = (name: string, blob) => {
const data = new Blob([atob(blob)], { type: 'application/pdf' });
const url = URL.createObjectURL(data); console.log(url);
const link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('download', name);
link.addEventListener('click', () => {
setTimeout(() => {
URL.revokeObjectURL(url);
});
});
link.click();
};
Failed to execute 'atob' on 'Window': The string to be decoded contains characters outside of the Latin1 range
const d = (name, blob) => {
const url = URL.createObjectURL(blob);
// code
}
const download = (name: string, blob) => {
const byteCharacters = new Uint8Array(blob.length);
for (let i = 0; i < blob.length; i++) {
byteCharacters[i] = blob.charCodeAt(i);
}
const data = new Blob([byteCharacters], { type: 'application/pdf' });
const url = URL.createObjectURL(data);
console.log(url);
const link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('download', name);
link.addEventListener('click', () => {
setTimeout(() => {
URL.revokeObjectURL(url);
});
});
link.click();
};