function commerce_invoice_pdf_generate in Commerce Invoice 7.2
Generate a PDF for an invoice.
Parameters
\Drupal\commerce_invoice\Entity\Invoice $invoice:
Return value
string The PDF contents, as a string.
1 call to commerce_invoice_pdf_generate()
- commerce_invoice_pdf_create in modules/
pdf/ commerce_invoice_pdf.module - Create a PDF for an invoice.
File
- modules/
pdf/ commerce_invoice_pdf.module, line 137 - The Commerce Invoice PDF module.
Code
function commerce_invoice_pdf_generate(Invoice $invoice) {
$dompdf = commerce_invoice_pdf_load_dompdf();
if (!$dompdf) {
throw new RuntimeException('The DOMPDF library was not found.');
}
$html = theme('commerce_invoice_pdf_page', [
'invoice' => $invoice,
]);
$dompdf
->set_paper('a4', 'portrait');
$dompdf
->load_html($html);
$dompdf
->render();
return $dompdf
->output();
}