Open uginroot opened 4 years ago
Can you tell us what do you expect and what actually happens?
You pasted a try-catch, so i assume it raises an exception and returns null
? Or does it runs into a fatal error?
The problem is that after an exception the output stops working and the application starts consuming a lot of memory.
The solution that helped me temporarily cope with this problem:
function pdf2text($path): ?string
{
$content = file_get_contents($path);
if(strpos($content, '%PDF') !== 0){
return null;
}
try{
$parser = new Parser();
return $parser->parseContent($content)->getText();
} catch (\Exception $exception){
return null;
}
}
Problems:
Broken file
Example: