<?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;
}