false, 'content' => null, 'error' => 'PDF file not found.', ]; } try { $parser = new Parser(); $pdf = $parser->parseFile($filePath); $text = $pdf->getText(); $text = trim($text); if (empty($text)) { return [ 'success' => false, 'content' => null, 'error' => 'The PDF appears to be empty or contains no extractable text.', ]; } return [ 'success' => true, 'content' => $text, 'error' => null, ]; } catch (\Exception $e) { Log::error('PDF extraction error: ' . $e->getMessage(), [ 'file' => $filePath, ]); return [ 'success' => false, 'content' => null, 'error' => 'Failed to extract text from PDF: ' . $e->getMessage(), ]; } } }