kompass/includes/pdfhandler.php

21 lines
397 B
PHP
Raw Permalink Normal View History

2024-05-27 16:59:30 +02:00
<?php
use Dompdf\Dompdf;
use Dompdf\Options;
function kompass_create_pdf (string $content, string $filename, string $format = 'portrait', bool $force_download = true): ?string {
$dompdf = new Dompdf();
$dompdf->setPaper('A4', $format);
$dompdf->loadHtml($content);
$dompdf->render();
if (!$force_download) {
return $dompdf->output();
}
$dompdf->stream( $filename );
return null;
}