简体   繁体   中英

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

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'
]]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM