* Initial plan * Fix PDF export filename: use JavaScript download with proper .pdf extension Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Remove test PDF file from repository Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Add year and month --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
18 lines
No EOL
660 B
JavaScript
18 lines
No EOL
660 B
JavaScript
window.downloadFile = (filename, contentType, base64Data) => {
|
|
const byteCharacters = atob(base64Data);
|
|
const byteNumbers = new Array(byteCharacters.length);
|
|
for (let i = 0; i < byteCharacters.length; i++) {
|
|
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
}
|
|
const byteArray = new Uint8Array(byteNumbers);
|
|
const blob = new Blob([byteArray], { type: contentType });
|
|
|
|
const url = window.URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = filename;
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
document.body.removeChild(a);
|
|
window.URL.revokeObjectURL(url);
|
|
}; |