<?php
// Include Composer's autoloader
require '../vendor/autoload.php';

// Ensure that txtFile is set and not empty
if ($_REQUEST["txtFile"] != "") {

	ob_start();
	$Orientation = $_REQUEST["txtOrientation"];

	if ($Orientation == "") {
		$Orientation = "P"; // Default to Portrait
	}

	$filename = "../report/" . $_REQUEST["txtFile"];
	$PDFFileName = str_replace(".html", ".pdf", $filename);

	// Get the HTML content of the file
	$html = file_get_contents($filename);
	//echo $html;exit;

	$mpdf = new \Mpdf\Mpdf();

	// Set orientation
	$mpdf->DefOrientation = $Orientation;

	// Write the HTML content to the PDF
	$mpdf->WriteHTML($html);

	ob_end_clean();
	
	// Output the PDF
	$mpdf->Output();
	
	// Clean up
	unset($html);


}
?>