fix pdf generation

This commit is contained in:
Emily
2024-06-06 15:15:34 +02:00
parent c0a9194cb9
commit 04d035fa97
2 changed files with 18 additions and 10 deletions

View File

@@ -6,17 +6,22 @@ const activeProject = useActiveProject();
async function generatePDF() {
const res = await $fetch<Blob>('/api/project/generate_pdf', {
...signHeaders(),
responseType: 'blob'
});
const url = URL.createObjectURL(res);
const a = document.createElement('a');
a.href = url;
a.download = `Report.pdf`;
a.click();
URL.revokeObjectURL(url);
try {
const res = await $fetch<Blob>('/api/project/generate_pdf', {
...signHeaders(),
responseType: 'blob'
});
const url = URL.createObjectURL(res);
const a = document.createElement('a');
a.href = url;
a.download = `Report.pdf`;
a.click();
URL.revokeObjectURL(url);
} catch (ex: any) {
alert(ex.message);
}
}
</script>