pdfparser icon indicating copy to clipboard operation
pdfparser copied to clipboard

pdf with background image/color gives Invalid object reference for $obj. Error

Open MadOMax opened this issue 3 years ago • 11 comments

Exception: Invalid object reference for $obj. in Smalot\PdfParser\RawData\RawDataParser->getindirectObject() (line 528 in vendor/smalot/pdfparser/src/Smalot\PdfParser/RawData/RawDataParser.php) im using v1.1.0, I tried the latest version but still get the same issue.

MadOMax avatar Aug 22 '22 00:08 MadOMax

Thanks for reporting. I could not find the place you referenced in https://github.com/smalot/pdfparser/blob/master/src/Smalot/PdfParser/RawData/RawDataParser.php#L507. Can you check again in the latest version of RawDataParser.php and give me an exact line number?

k00ni avatar Aug 22 '22 07:08 k00ni

Thanks @k00ni , line number is 528. This throw an error when some pdf files only. pdf files with background image/color may return this issue.

MadOMax avatar Aug 23 '22 06:08 MadOMax

I have the same issue, if you want a PDF that generates this error, I can post or send in private. Let me know.

klode82 avatar Sep 22 '22 08:09 klode82

That would be helpful, if the PDF is free of charge and can be part of our test environment. In this case please attach it to this issue, so we have a secure place + link. Thanks.

k00ni avatar Sep 22 '22 08:09 k00ni

The PDF is free of charge, but it contains personal information... However, I can send to you in private.

klode82 avatar Sep 22 '22 08:09 klode82

The PDF is free of charge, but it contains personal information... However, I can send to you in private.

That is unfortunate. Adding PDFs to related issues is the preferred way here, because it makes sure PDF are not removed in the meantime until someone finds time to work on a fix.

Please do not send it to me in private. I am just a maintainer here (e.g. collecting relevant information for issues, help organizing steps to get a new PR merged etc.) and I don't have time for bug fixing in my spare time, unfortunately.

k00ni avatar Sep 22 '22 09:09 k00ni

I have met the same problem with a minimum blank PDF generated by PDF Factory. It raises the same exception at the same line (528 in RawDataParser.php). As it contains no personal data (in fact, it contains no data at all!) I can share it.

Blanco.pdf

ajgelado avatar Nov 16 '22 02:11 ajgelado

Thanks @ajgelado

k00ni avatar Nov 16 '22 07:11 k00ni

I get the same error parsing a PDF document with a table. I cannot post the file, but I'm assuming that the error is caused by the last column in the table, that couldn't be displayed in the PDF, but the parser expects the same. The error line has slightly changed from 528 to 529

Invalid object reference for $obj. {myprojectfolder}/vendor/smalot/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php#529

edwink75 avatar Jul 03 '23 12:07 edwink75

I can confirm and have set this in vendor/smalot/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php#528

if (2 !== \count($objRefArr)) { return []; throw new \Exception('Invalid object reference for $obj.'); }

but this is a interim solution... Is there a better solution in the meantime??

Michael

mschrading avatar Nov 05 '23 13:11 mschrading

I believe this error is caused by the pdf version. After i opened and saved my pdf in an pdf editor, the pdf version updated from 1.3 to 1.5 and the error was gone.