(file: File)
| 45 | * This is used as a fallback when remote API fails. |
| 46 | */ |
| 47 | export async function extractPdfText(file: File): Promise<string> { |
| 48 | console.log("[PDF] Using client-side extraction with unpdf...") |
| 49 | const buffer = await file.arrayBuffer() |
| 50 | const pdf = await getDocumentProxy(new Uint8Array(buffer)) |
| 51 | const { text } = await extractText(pdf, { mergePages: true }) |
| 52 | console.log("[PDF] Client-side extraction completed, text length:", (text as string).length) |
| 53 | return text as string |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Check if a file is a PDF |
no outgoing calls
no test coverage detected