feat: protect pdf

This commit is contained in:
Ibrahima G. Coulibaly
2025-04-03 18:42:24 +00:00
parent 141a0a3a24
commit 5545f0f344
11 changed files with 369 additions and 58 deletions

View File

@@ -0,0 +1,16 @@
export function loadPDFData(url: string, filename: string): Promise<File> {
return new Promise((resolve) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
window.URL.revokeObjectURL(url);
const blob = new Blob([xhr.response], { type: 'application/pdf' });
const newFile = new File([blob], filename, {
type: 'application/pdf'
});
resolve(newFile);
};
xhr.send();
});
}