debug=true; $mpdf->tabSpaces = 6; //============================================================== preg_match('/example[0]{0,1}(\d+)_(.*?)\.php/',$filename,$m); $num = intval($m[1]); $title = ucfirst(preg_replace('/_/',' ',$m[2])); if (!$num || !$title) { die("Invalid file"); } $html = '

mPDF

Example '.$num.'. '.$title.'

'; $text = file_get_contents($filename); $html .= PreparePreText($text); $html .= '
'; $mpdf->WriteHTML($html,2); // The 2 is important to prevent