CleverIT / UBL_invoice

MIT License
36 stars 39 forks source link

Unable to add PDF file as attachement #14

Closed ThomasVdBerge closed 5 years ago

ThomasVdBerge commented 5 years ago

I am trying to add a PHP file as attachement to my UBL document.

$pdfInvoice =  new \SplFileInfo('/tmp/test.pdf');
$additionalDocumentReference = new AdditionalDocumentReference();
$additionalDocumentReference->setFilename('test.pdf');
$additionalDocumentReference->setAttachment($pdfInvoice);

This however gives me the following error

The writer cannot serialize objects of class: SplFileInfo

Which made me wonder, what type of input is expected for an attachement?

baselbers commented 5 years ago

The pdf file needs to be in binary code. Use base64_encode() and set it to the attachment element.