<?php  
 ob_start();
session_start();
include ('../includes/connection.php');   
$id=$_GET['Id_2'];
$id_2=$_GET['Id_3'];
$school_query = mysqli_query($conn,"SELECT * FROM subject_soes,sms_result,student_soes WHERE sms_result.student_id = student_soes.student_id AND subject_soes.subject_id=sms_result.subject_id AND subject_soes.course_code='$id' AND student_soes.student_id='$id_2';");
$exam_1 = mysqli_fetch_array($school_query); 
$subject_name=$exam_1['subject_name'];
$student_name = $exam_1['student_name'];
 $html .= ' <style>
   body {
      margin: 0;
      padding: 0;
    }
    .certificate {
      width: 1024px;
      height: 700px;
      background-image: url("../assets/img/1.png");  
      background-size: cover;
      background-position: center;
      position: relative;
      font-family: "Georgia", serif;
      margin: 0px auto; 
    }
    .name {
      position: absolute;
      top: 330px; /* adjust as needed */
      left: 50%;
      transform: translateX(-50%);
      font-size: 36px;
      font-weight: bold;
      color: #000;
    }
    .course {
      position: absolute;
      top: 460px; /* adjust as needed */
      left: 50%;
      transform: translateX(-50%);
      font-size: 24px;
      font-style: italic;
      color: #fff;
    }
    .cdate {
      position: absolute;
      top: 549px; /* adjust as needed */
      left: 87%;
      transform: translateX(-50%);
      font-size: 16px;
      font-style: italic;
      color: #000;
    }
    .vdate {
      position: absolute;
      top: 595px; /* adjust as needed */
      left: 87%;
      transform: translateX(-50%);
      font-size: 16px;
      font-style: italic;
      color: #000;
    }
 
</style>'; 
      
                           
$html .= '<div class="certificate">
  <div class="name">'. $student_name . '</div>
  <div class="course">'. $subject_name . '</div>
  <div class="cdate">06-12-2025</div>
  <div class="vdate">30-12-2027</div>
</div>';  

 




require_once '../dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf(); 
$dompdf->loadHtml($html); 
$dompdf->setPaper('A4', 'landscape'); 
$dompdf->render();
$dompdf->stream(' '. $student_name . '.pdf');

?>