-
Notifications
You must be signed in to change notification settings - Fork 563
Open
Labels
Description
- PHP Version: 8.0
- PDFParser Version: 2.12.0
Description: With this PDF I get this error: "Invalid object reference for $obj." on line 544 of the file RawDataParser.php
PDF input
Expected output & actual output
The text of the file
Code
$parser = new \Smalot\PdfParser\Parser();
// Leemos el PDF
try {
$config = new \Smalot\PdfParser\Config();
$config->setIgnoreEncryption(true);
$pdf = $parser->parseFile($pdfGenCu_FicheroTemporalRecibido, $config);
// Sacamos el texto y por si acaso, lo pasamos todo a mayúsculas
$contenidoPDF = $pdf->getText();
$contenidoPDF = strtoupper($contenidoPDF);
// Vamos a quitar los dobles espacios si hubiera
$contenidoPDF = preg_replace('/\s\s+/', ' ', $contenidoPDF);
} catch (Exception $e) {
$alert_text = 'Error al procesar el PDF: ' . $e->getMessage();
if (method_exists($e, 'getLine') && $e->getLine() !== null) {
$alert_text .= ' en la línea ' . $e->getLine();
}
if (method_exists($e, 'getFile') && $e->getFile() !== null) {
$alert_text .= ' en el fichero ' . $e->getFile();
}
}