How can I embed a file as an attachment to a pdf file via php?

853 Views Asked by At

I want to embed generated ZUGFeRD Data to a PDF file (generated via FPDF). I think it's not possible using FPDF directly. So the PDF file must be opened after it's written. How can I do this without command line tools? The site is hosted on a server, where I cannot install any command line tools.

ZUGFeRD is literally a XML file (german standard for exchange of invoices to make it easier for computers to read the document).

This is an example, how it should look like

1

There are 1 best solutions below

0
J. Staerk On

When talking of the "simple attachment" you speak about PDF/A-3 file attachments, all of which require custom PDF/A Schema Extensions. If you have at least a PDF/A-1 compliant file you can use @GPs library https://packagist.org/packages/atgp/factur-x to convert to PDF/A-3 and attach the XML.