atgp / factur-x

PHP library to manage your Factur-X / ZUGFeRD 2.0 PDF invoices files
MIT License
87 stars 22 forks source link

Exception: Invalid PDF data: missing %PDF header #34

Closed JanickSYSL closed 2 months ago

JanickSYSL commented 2 months ago

I have the following problem when I call $reader->extractXML($pdfFile);.

The PDF is attached. What could be causing the problem?

Unable to get Factur-X Xml from PDF : Exception: Invalid PDF data: missing %PDF header. in /home/www-data/vendor/smalot/pdfparser/src/Smalot/PdfParser/RawData/RawDataParser.php:945 Stack trace:

0 /home/www-data/vendor/smalot/pdfparser/src/Smalot/PdfParser/Parser.php(103): Smalot\PdfParser\RawData\RawDataParser->parseData('/out/EN16931_Ei...')

1 /home/www-data/vendor/atgp/factur-x/src/Reader.php(35): Smalot\PdfParser\Parser->parseContent('/out/EN16931_Ei...')

2 /home/www-data/_imap_zugferd.php(61): Atgp\FacturX\Reader->extractXML('/out/EN16931_Ei...')

3 /home/www-data/_imap_zugferd.php(35): extractZUGFeRDXML('/out/EN16931_Ei...', '/out/')

4 /home/www-data/.php(21): _imap_zugferd('{cas.hostedsolu...', 'operating@syslo...', '---------...', '/out/')

5 {main}

EN16931_Einfach.pdf

benito103e commented 2 months ago

Hello @JanickSYSL, You should use Reader to extract data from pdf content and not from pdf filename. See : \Atgp\FacturX\Reader::extractXML(pdfBinary) @param string $pdfBinary content of the PDF invoice