'How to Generate PDF invoice to XML format using mPDF
I have a pdf invoice format and want to generate xml invoice format as per ZATCA if any did it please need help.
I saw this in mPDF but didn't figure it out how to achieve it!
'PDFA' => true,
'PDFAauto' => true,
//'PDFAversion'=> 'A-3',
]);
$mpdf->SetAssociatedFiles([[
'name' => 'public_filename.xml',
'mime' => 'text/xml',
'description' => 'some description',
'AFRelationship' => 'Alternative',
'path' => __DIR__ . '/TaxInvoice.xml'
]]);
$rdf = '<rdf:Description rdf:about="" xmlns:zf="urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#">'."\n";
$rdf .= ' <zf:DocumentType>INVOICE</zf:DocumentType>'."\n";
$rdf .= ' <zf:DocumentFileName>ZUGFeRD-invoice.xml</zf:DocumentFileName>'."\n";
$rdf .= ' <zf:Version>1.0</zf:Version>'."\n";
$rdf .= ' <zf:ConformanceLevel>BASIC</zf:ConformanceLevel>'."\n";
$rdf .= '</rdf:Description>'."\n";
$mpdf->SetAdditionalXmpRdf($rdf);
I want more explanation from who did it before.
Thanks
Solution 1:[1]
first you have to create the XML file then include it inside SetAssociatedFiles
like this:
your code:
'PDFA' => true,
'PDFAauto' => true,
//'PDFAversion'=> 'A-3',
]);
$mpdf->SetAssociatedFiles([[
'name' => 'public_filename.xml',
'mime' => 'text/xml',
'description' => 'some description',
'AFRelationship' => 'Alternative',
'path' => __DIR__ . '/TaxInvoice.xml'
]]);
$rdf = '<rdf:Description rdf:about="" xmlns:zf="urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#">'."\n";
$rdf .= ' <zf:DocumentType>INVOICE</zf:DocumentType>'."\n";
$rdf .= ' <zf:DocumentFileName>ZUGFeRD-invoice.xml</zf:DocumentFileName>'."\n";
$rdf .= ' <zf:Version>1.0</zf:Version>'."\n";
$rdf .= ' <zf:ConformanceLevel>BASIC</zf:ConformanceLevel>'."\n";
$rdf .= '</rdf:Description>'."\n";
$mpdf->SetAdditionalXmpRdf($rdf);
I edited:
'PDFA' => true,
'PDFAauto' => true,
//'PDFAversion'=> 'A-3',
]);
$mpdf->SetAssociatedFiles([[
'name' => 'thisisfilecreatedbympdf.xml',
'mime' => 'text/xml',
'description' => 'some description',
'AFRelationship' => 'Alternative',
'path' => __DIR__ . '/hereyourxmlinvoice.xml'
]]);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |