I have XML in a base64Encoded string. My requirement is to attach base64Encoded xml into pdf. I am using the following example, which is getting XML from a file, but I need to first decode base64Encoded xml then attach it with a pdf
$mpdf = new MpdfMpdf([
'PDFA' => true,
'PDFAauto' => true,
]);
$mpdf->SetAssociatedFiles([[
'name' => 'phpunit.xml',
'mime' => 'text/xml',
'description' => 'some description',
'AFRelationship' => 'Alternative',
'path' => base_path() . '/phpunit.xml'
]]);
$mpdf->WriteHTML('<h1>Hello world 1!</h1>');
return $mpdf->Output();
The above example works fine if we pass XML file path, but I have XML in base64 encoded string. How can we attach base64Encoded xml into pdf using Mpdf
library in Laravel/PHP
?
2
Answers
You can attach a base64-encoded XML string as a file in a PDF using the Mpdf library like the following.
To attach data contained in a string, you need to use the
content
entry: