I have a PDF file and I want to attach / merge / embed an XML file what containt the same datas like PDF but readable for computers. Is there any way in PHP to do this?
I don't have any code or idea how to start this.
Thanks!
I have a PDF file and I want to attach / merge / embed an XML file what containt the same datas like PDF but readable for computers. Is there any way in PHP to do this?
I don't have any code or idea how to start this.
Thanks!
One solution would be to store the XML inside a XMP block in the PDF. XMP is a metadata extension. It allows to define own Schemas. Basically it's RDF/XML.
SPEC: http://partners.adobe.com/public/developer/en/xmp/sdk/XMPspecification.pdf
I have not seen a XMP writer for PDF in PHP, yet.
But it can't be that hard to implement it.
When looking at the reader, it's basically RDF content wrapped inside a <x:xmpmeta
block.
Some pointers:
Another solution would be to use PDF "attachments".
You could work with the PHP lib FPDF. Here is an example to add an attachment: