如何使用 mPDF 将 PDF 发票生成为 XML 格式
How to Generate PDF invoice to XML format using mPDF
我有一个 pdf 发票格式,想根据 ZATCA 生成 xml 发票格式,如果有的话需要帮助。
我在 mPDF 中看到了这个,但没有弄清楚如何实现它!
'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);
我想听听之前是谁做的更多解释。
谢谢
首先您必须创建 XML 文件,然后将其包含在 SetAssociatedFiles
中,如下所示:
您的代码:
'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);
我编辑了:
'PDFA' => true,
'PDFAauto' => true,
//'PDFAversion'=> 'A-3',
]);
$mpdf->SetAssociatedFiles([[
'name' => 'thisisfilecreatedbympdf.xml',
'mime' => 'text/xml',
'description' => 'some description',
'AFRelationship' => 'Alternative',
'path' => __DIR__ . '/hereyourxmlinvoice.xml'
]]);
我有一个 pdf 发票格式,想根据 ZATCA 生成 xml 发票格式,如果有的话需要帮助。
我在 mPDF 中看到了这个,但没有弄清楚如何实现它!
'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);
我想听听之前是谁做的更多解释。
谢谢
首先您必须创建 XML 文件,然后将其包含在 SetAssociatedFiles
中,如下所示:
您的代码:
'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);
我编辑了:
'PDFA' => true,
'PDFAauto' => true,
//'PDFAversion'=> 'A-3',
]);
$mpdf->SetAssociatedFiles([[
'name' => 'thisisfilecreatedbympdf.xml',
'mime' => 'text/xml',
'description' => 'some description',
'AFRelationship' => 'Alternative',
'path' => __DIR__ . '/hereyourxmlinvoice.xml'
]]);