This question already has an answer here:
- Multi-line strings in PHP 8 answers
how can i replace php variable into html content by using mpdf? for example below code, i want to display variable purchasetype
in html content.
<?php
$PurchaseType = "Cash";
$html = '
<html>
<body>
<label> variable here : "phpvariable" </label>
</body>
</html>
';
$path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once $path . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("Acme Trading Co. - Invoice");
$mpdf->SetAuthor("Acme Trading Co.");
$mpdf->SetWatermarkText("Paid");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->WriteHTML($html);
$mpdf->Output();
</div>