Verify stored PDF retry in browser and clarify upload errors
This commit is contained in:
@@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user