Open Saulight73 opened 7 months ago
@k00ni any news about this issue ? we can't work well parsing PDF's with 2.10 version. its also the same error :
[Tue May 28 10:46:34.576806 2024] [proxy_fcgi:error] [pid 3767717] [client 10.1.21.27:53967] AH01071: Got error 'PHP message: PHP Warning: Undefined array key 0 in /var/www/clients/client1/web10/web/application/library/php/pdfparser-2.10.0/src/Smalot/PdfParser/Page.php on line 279; PHP message: PHP Fatal error: Uncaught TypeError: Smalot\PdfParser\Page::getPDFObjectForFpdf(): Return value must be of type Smalot\PdfParser\PDFObject, null returned in /var/www/clients/client1/web10/web/application/library/php/pdfparser-2.10.0/src/Smalot/PdfParser/Page.php:279\nStack trace:\n#0 /var/www/clients/client1/web10/web/application/library/php/pdfparser-2.10.0/src/Smalot/PdfParser/Page.php(399): Smalot\PdfParser\Page->getPDFObjectForFpdf()\n#1 /var/www/clients/client1/web10/web/application/library/php/pdfparser-2.10.0/src/Smalot/PdfParser/Page.php(424): Smalot\PdfParser\Page->extractRawData()\n#2 /var/www/clients/client1/web10/web/application/library/php/pdfparser-2.10.0/src/Smalot/PdfParser/Page.php(504): Smalot\PdfParser\Page->extractDecodedRawData()\n#3 /var/www/clients/client1/web10/web/application/library/php/pdfparser-2.10.0/src/Smalot/PdfParser/Page.php(655): Smalot\PdfParser\Page->getDataCommands()\n#4 /var/www/clients/client1/web10/web/application/library/php/Glenat/App/DocuSignApp....', referer: http://core-test.glenat.com/
Please upload a PDF here which causes this problem.
Here it is.
I tried your PDF, but PDFParser reported a different error:
PHPUnitTests\Integration\ParserTest::testIssue703 Exception: Invalid object reference for $obj. /var/www/html/src/Smalot/PdfParser/RawData/RawDataParser.php:536 /var/www/html/src/Smalot/PdfParser/RawData/RawDataParser.php:242 /var/www/html/src/Smalot/PdfParser/RawData/RawDataParser.php:918 /var/www/html/src/Smalot/PdfParser/RawData/RawDataParser.php:952 /var/www/html/src/Smalot/PdfParser/Parser.php:103 /var/www/html/tests/PHPUnit/Integration/ParserTest.php:446 phpvfscomposer:///var/www/html/dev-tools/vendor/phpunit/phpunit/phpunit:106
Here is my test code (separate branch issue/703
):
I may have made a mistake somewhere, can you have a look please?
$localPdfPath = './tpm.pdf'; file_put_contents($localPdfPath, file_get_contents($pdfLink)); $pdf = $parser->parseFile($localPdfPath);
here it our code same as yours so didnt know why you have different error! Can you try to save localy the pdf in en tmp file like use maybe solve this problem
I tried it locally and got the error I mentioned. After #719 got merged, we can run CI for side-branches too and will see if the same error occurs.
#719 got merged.
My last found error is also shown online for your given PDF, for instance here for PHP 7.2: https://github.com/smalot/pdfparser/actions/runs/9386160259/job/25846037622#step:6:37 (or the same error here for PHP 8.3)
Exception: Invalid object reference for $obj. /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:536 /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:242 /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:918 /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:952 /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/Parser.php:103 /home/runner/work/pdfparser/pdfparser/tests/PHPUnit/Integration/ParserTest.php:453
Also, which PHP version do you use?
Btw. might be the same error as in #714
#719 got merged.
My last found error is also shown online for your given PDF, for instance here for PHP 7.2: https://github.com/smalot/pdfparser/actions/runs/9386160259/job/25846037622#step:6:37 (or the same error here for PHP 8.3)
Exception: Invalid object reference for $obj. /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:536 /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:242 /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:918 /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:952 /home/runner/work/pdfparser/pdfparser/src/Smalot/PdfParser/Parser.php:103 /home/runner/work/pdfparser/pdfparser/tests/PHPUnit/Integration/ParserTest.php:453
Also, which PHP version do you use?
Btw. might be the same error as in #714
We use PHP 8.2 and before we try in PHP 8.3 i can give you some others PDF if you want generated with other parameters and version :
test3_fpdfSeul.pdf test4_iso.pdf test5_serveurapache.pdf test6_serveurapacheIso.pdf test7_serveurapacheIsoV1.pdf test9_V2-1.pdf test9_V2-2.pdf test9_V2-3.pdf test10-V2-bloc-fin.pdf test11-v2-blocFin.pdf
The error we have in our logs comes from when we parse the data of the pages. We are using a PDF generated by the latest version of FPDF, version 1.86. However, the last version where this error did not occur is 1.81. Therefore, we would like to have, if possible, an idea of what could be causing this error:
Undefined array key 0 in /var/www/clients/client1/web10/web/application/library/php/pdfparser-2.5.0/src/Smalot/PdfParser/Page.php on line 284.
Even with version 2.9.0 of your parser, the error persists. Therefore, I am attaching my PHP parsing code below:
Thank you for providing us with prompt assistance for our production solution.
Best regards,
GLENAT Group