<?PHP
/**
* generates pdf file
*/
class Pdf{
	/**
	* pdf generator
	* @param String $html AS html images must be /var/www/image.png
	* @param String $file AS source file
	* @param String $file_name = 'sample.pdf' AS destination file
	* @param String $action='show' AS show, write
	*/
	function pdfGenerator($html, $file, $file_name = 'sample.pdf', $action='show'){

		require_once _RootFolder.'/core/classes/dompdf/dompdf_config.inc.php';

		$dompdf = new DOMPDF();
		if($file){

			$dompdf->load_html_file($file);
		}
		else{

			$dompdf->load_html($html);
		}
		$dompdf->set_paper('a4', 'portrait');
		$dompdf->render();

		if($action == 'show')
			$dompdf->stream($file_name);

		if($action == 'write')
			file_put_contents($file_name, $dompdf->output());
	}
}
?>