I use mPDF library to generate PDF/A-3 file, everything work fine except
- my pdf file output from this library indicate file to only conform with PDF/A-1B.
- my XML attachment in pdf document’s output indicate to be 0.00Bytes although I can open attached file and see detail.
How to fix this issue? Here is some of my code.
$defaultConfig = (new MpdfConfigConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new MpdfConfigFontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new MpdfMpdf([
'format' => [210, 297]
, 'mirrorMargins' => 1
, 'mode' => 'utf-8'
, 'PDFA' => true
, 'PDFAauto' => false
, 'PDFAversion'=> 'A-3'
, 'fontDir' => array_merge($fontDirs, [
$_SERVER['DOCUMENT_ROOT'] . '/font',
])
, 'fontdata' => $fontData + [ // lowercase letters only in font key
'sarabun' => [
'R' => 'THSarabunNew.ttf'
, 'B' => 'THSarabunNew Bold.ttf'
]
]
, 'default_font' => 'sarabun'
, 'debug' => true
]);
$mpdf->SetAssociatedFiles([[
'name' => $invoiceNumber . '.xml'
, 'mime' => 'text/xml'
, 'description' => 'Tax Invoice XML Data'
, 'AFRelationship' => 'Alternative'
, 'content' => $xml
]]);
$mpdf->SetAdditionalXmpRdf($rdf);
$mpdf->SetTitle($invoiceNumber);
$mpdf->SetAuthor($masterCompany['companyName']);
$mpdf->SetCreator($masterCompany['companyName']);
$mpdf->SetSubject('Receipt/Tax Invoice');
$mpdf->SetKeywords('Tax Invoice');
$mpdf->WriteHTML($html);
$mpdf->Output($invoiceNumber . '.pdf', 'I');
I can’t find much examples in detail how to output PDF/A-3 document from mPDF from the internet. Here is what I got from there website https://mpdf.github.io/what-else-can-i-do/pdf-a3-xmp-rdf.html