Refactor PDF mounting process to use ArrayBuffer

Changed mountPdf function to accept an ArrayBuffer instead of a URL. This improves handling of documents by simplifying the data flow and eliminates the need for URL object creation.
This commit is contained in:
2024-10-23 22:08:25 +02:00
parent 00408b91a9
commit 4e0a421a03

View File

@@ -277,8 +277,8 @@ const signature = window.signature;
console.log(signature);
const mountPdf = async (url: string) => {
const loadingTask = pdfjsLib.getDocument(url);
const mountPdf = async (doc: ArrayBuffer) => {
const loadingTask = pdfjsLib.getDocument(doc);
pdf = await loadingTask.promise;
pageCount.value = pdf.numPages;
await setPage(page.value);
@@ -317,7 +317,8 @@ async function downloadAndOpen(): Promise<Blob> {
console.error("error while downloading and decrypting document", e);
throw e;
}
await mountPdf(URL.createObjectURL(raw));
const doc = await raw.arrayBuffer();
await mountPdf(doc);
return raw;
}