<?php

use Dompdf\Dompdf;
use Dompdf\Options;

function generatePDF($html, $filename = 'laporan.pdf', $paper = 'A4', $orientation = 'portrait')
{
    $options = new Options();
    $options->set('defaultFont', 'Arial');
    $options->set('isRemoteEnabled', true); // Untuk load gambar dari URL
    
    $dompdf = new Dompdf($options);
    $dompdf->loadHtml($html);
    $dompdf->setPaper($paper, $orientation);
    $dompdf->render();
    $dompdf->stream($filename, ['Attachment' => false]);
    exit();
}