<?php
	
	 //starting session if not already started
    if (!session_start()) {
        session_start();
    }

    //redirecting when no type
    if (!isset($_SESSION['type']))
	{
	 	header("location: /students_idcards");

    } 

	//includes functions and classes
	if ($_SESSION['type'] == 'nce') 
	{
	 	include_once 'includes/functions.php';

    } elseif ($_SESSION['type'] == 'prence') {
    	include_once 'includes/functions_prence.php';
    } 
	
	include_once ('do.php');
    
	
	include_once('pdfSample/print.php');
	$Template = ob_get_clean();
	//include dompdf library
	require_once('dompdf/autoload.inc.php');
	use Dompdf\Dompdf;
	//using  pdf dompdf class
	$Dompdf = new Dompdf();
	$Dompdf->set_option('isHtml5ParserEnabled', TRUE);
	$Dompdf->loadHtml($Template);
		//temporarily use it 
    ob_end_clean();
	//set paper size
	//$Dompdf->setPaper('A4','Landscape');
	$Dompdf->setPaper('A4','Portrait');
    
	//render Html to pdf
	$Dompdf->render();

	$mat_num = str_replace('/', '-', $mat_num);

	//clearing sessions
	/*if (isset($_SESSION['type']))
	{
	 	unset($_SESSION['type']);

    } 
    if (isset($_SESSION['p']))
	{
	 	unset($_SESSION['p']);

    } */
    
    
    ///for finding header already
    /*	$f;
    $l;
    if(headers_sent($f,$l))
    {
        echo $f,'<br/>',$l,'<br/>';
        die('now detect line');
    }*/
	//display to browser
	$Dompdf->stream($mat_num .'-IDCard');
	//write pdf to directory
	//file_put_contents('pdf/Report-'.time().'.pdf',$Dompdf->output());
	//file_get_contents('pdf/Report-'.time().'.pdf',$Dompdf->output());


?>