<?php

require_once('php/config.php');
$data = str_replace('style="display: none;"','',$_POST['vpdfdata']);


include('php/mpdf/mpdf.php');

$mpdf=new mPDF();
$mpdf->allow_charset_conversion = true;
$mpdf->WriteHTML('<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
$mpdf->WriteHTML('<link href="css/bootstrap.css" rel="stylesheet">');
$mpdf->WriteHTML('<link href="css/custom.css" rel="stylesheet">');
$mpdf->WriteHTML('<link href="css/skins/'.$skin.'" rel="stylesheet" type="text/css">');
$mpdf->WriteHTML('<style>
					@page {
    background: url("img/billie_holiday.png") repeat;
}
				</style>
				</head>');
$mpdf->WriteHTML($data);

if($_POST['type'] == '1'){
	$mpdf->Output();
	exit;
}
else{
	$file = 'data/exports/'.uniqid().'.pdf';
	$mpdf->Output($file,'F');
	header('Content-Description: File Transfer');
	header('Content-Type: application/octet-stream');
	header('Content-Disposition: attachment; filename='.basename($file));
	header('Content-Transfer-Encoding: binary');
	header('Expires: 0');
	header('Cache-Control: must-revalidate');
	header('Pragma: public');
	header('Content-Length: ' . filesize($file));
	readfile($file);
	unlink($file);
	exit;
}
