Open PrimeGhostDE opened 1 month ago
Hi together, is there something new to this?
In your code the variable $embeddedFiles
is never defined:
$pdfParsed->getObjectsByType('EmbeddedFile');
foreach ($embeddedFiles as $embeddedFile) {
$embeddedFile->getContent(); // returns Undefined variable $embeddedFile
}
It should complain that $embeddedFiles
is not defined. What happens when you do $embeddedFiles = $pdfParsed->getObjectsByType('EmbeddedFile')
before the loop?
You are right. I copied it to github without the assignment. But it stays the same -> it does not work as expected.
$pdfParser = new PdfParser();
$pdfContent = file_get_contents(Storage::path($dokument->path . '/' . $dokument->filename));
$pdfParsed = $pdfParser->parseContent($pdfContent);
$embeddedFiles = $pdfParsed->getObjectsByType('EmbeddedFile');
dd($embeddedFiles); // returns array without any elements.
it does not get into the foreach.
Description:
I have analyzed the bug so far, that there is a problem concerning embeddedFiles.
PDF input
Example pdf invoice. Rechnung RE-202400282 vom 09.10.2024 zu Ihr Zeichen.pdf
Expected output & actual output
There is only one embedded File in it (please ignore why i use foreach here)
expected Output should be that the variable $embeddedFile is not undefined.
Code
see above :)
Kind regards