您好,我在其他项目中使用了dompdf,并且运行良好,这次我没有生成pdf,并且load_html函数将其调整为null,我的想法是告诉我:
Method 'load_html' is deprecated
这是我写的代码:
use Dompdf\Dompdf;
$dompdf = new DOMPDF();
$dompdf->set_option('isHtml5ParserEnabled', true);
$html = str_replace(
array(
'{{DOCUMENT}}',
'{{DATE}}',
'{{TITLE}}',
'{{USER_FIRSTNAME}}',
'{{USER_LASTNAME}}',
'{{SPECIALITY}}',
'{{DESC}}',
'{{PATIENT_FIRSTNAME}}',
'{{PATIENT_LASTNAME}}',
'{{INVOICE_NUMBER}}',
'{{PRICE}}',
'{{PRICE_TTC}}',
' class="no-tva"'
),
array(
'Facture',
date('d/m/Y'),
$_SESSION['cabinet_data_user']['infos']['title'],
substr($_SESSION['cabinet_data_user']['infos']['firstname'], 0, 1).'.',
$_SESSION['cabinet_data_user']['infos']['lastname'],
$_SESSION['cabinet_data_user']['infos']['speciality'],
$_user_desc,
ucfirst(mb_strtolower($invoice_pdf['firstname'])),
ucfirst(mb_strtolower($invoice_pdf['lastname'])),
isset($invoice_pdf['id']) ? $invoice_pdf['id'] : '123456',
number_format($invoice_pdf['price'], 2, ',', '.'),
($invoice_pdf['tva']) ?
number_format($invoice_pdf['price'] + $invoice_pdf['price'] * $invoice_pdf['tva'], 2, ',', '.') :
number_format($invoice_pdf['price'], 2, ',', '.'),
$invoice_pdf['tva'] ? '' : ' class="no-tva"'
),
file_get_contents(BASE.'params/templates/invoice.html')
);
unset($_user_desc);
$dompdf->load_html($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
任何建议都可以帮助,谢谢。