<?php
require 'vendor/autoload.php';

use Dompdf\Dompdf;
use Dompdf\Options;

$options = new Options();
$options->set('isRemoteEnabled', true);
$dompdf = new Dompdf($options);

// Get image content and convert to base64
$imagePath = realpath('./OHSC_certificates.jpg');
if (!$imagePath) {
    die('Image not found.');
}

$imageData = base64_encode(file_get_contents($imagePath));
$imageMimeType = mime_content_type($imagePath);

// Set image to A4 size (in points, 595x842 at 72 DPI)
$html = '
<style>
  body, html {
    margin: 0;
    padding: 0;
  }
  .full-page {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
</style>
<img class="full-page" src="data:' . $imageMimeType . ';base64,' . $imageData . '" /><div style="margin-top:-630px;"><table style="width:650px;margin-left:auto;margin-right:auto;" cellspacing="0" cellpadding="0"><tr><td height="55" valign="middle" align="center"  style="font-family:\'Times New Roman\', Times, serif;font-size:20pt;"><strong>Rizwan Aziz</strong></td></tr><tr><td style="height:50px;"> </td></tr><tr><td style="font-family:\'Times New Roman\', Times, serif;font-size:14pt;height:54px;text-align:center;"><strong>Project Management - Level 1</strong></td></tr></table><div style="margin-top:308px;margin-left:207px;font-family:\'Times New Roman\', Times, serif;font-size:11pt;"><strong>CAD12345</strong></div><div style="margin-left:136px;margin-top:20px;"><strong>13-jUNE-2025</strong></div>
';

$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream("document.pdf", ["Attachment" => false]);
?>
