mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-02-23 18:36:26 -05:00
21 lines
496 B
PHP
21 lines
496 B
PHP
<?php
|
|
|
|
/**
|
|
* PDF helper
|
|
*/
|
|
function create_pdf(string $html, string $filename = ''): string
|
|
{
|
|
// Need to enable magic quotes for the
|
|
$dompdf = new Dompdf\Dompdf(['isRemoteEnabled' => true, 'isPhpEnabled' => true]);
|
|
$dompdf->loadHtml(str_replace(['\n', '\r'], '', $html));
|
|
$dompdf->render();
|
|
|
|
if ($filename !== '') {
|
|
$dompdf->stream($filename . '.pdf');
|
|
} else { // TODO: Not all paths return a value.
|
|
return $dompdf->output();
|
|
}
|
|
|
|
return '';
|
|
}
|