Verify stored PDF retry in browser and clarify upload errors

This commit is contained in:
2026-09-06 09:41:17 +03:00
parent 277c9407a2
commit 01d4acf246
7 changed files with 358 additions and 2 deletions
+7 -1
View File
@@ -10,7 +10,13 @@ export async function extractPdfText(file, { maxPages = 40 } = {}) {
pdfjs.GlobalWorkerOptions.workerSrc = workerUrl;
const buf = await file.arrayBuffer();
const doc = await pdfjs.getDocument({ data: buf }).promise;
let doc;
try { doc = await pdfjs.getDocument({ data: buf }).promise; }
catch (error) {
if (error.name === 'InvalidPDFException') throw new Error('PDF dosyası bozuk veya geçerli PDF biçiminde değil.');
if (error.name === 'PasswordException') throw new Error('PDF parola korumalı; okunabilir bir kopyasını yükleyin.');
throw new Error('PDF okunamadı. Dosyayı kontrol edip yeniden deneyin.');
}
const pages = Math.min(doc.numPages, maxPages);
const parts = [];
for (let i = 1; i <= pages; i++) {