public function render($view = null, $layout = null) { try { ob_start(); if (defined('DOMPDF_TEMP_DIR')) { $dir = new SplFileInfo(DOMPDF_TEMP_DIR); if (!$dir->isDir() || !$dir->isWritable()) { trigger_error(__('%s is not writable', DOMPDF_TEMP_DIR), E_USER_WARNING); } } $errors = ob_get_contents(); ob_end_clean(); $download = false; $name = pathinfo($this->here, PATHINFO_BASENAME); $paperOrientation = 'portrait'; $paperSize = 'letter'; $preData = null; $postData = null; extract($this->viewVars, EXTR_IF_EXISTS); $dompdf = new DOMPDF(); $dompdf->set_protocol(''); $dompdf->set_protocol(WWW_ROOT); $dompdf->set_base_path('/'); $dompdf->set_paper($paperSize, $paperOrientation); if (!empty($preData) || !empty($postData)) { App::import('Vendor', 'Dompdf.PDFMerger', true, array(), 'PDFMerger' . DS . 'PDFMerger.php'); $merger = new PDFMerger(); if (!empty($preData)) { $merger->addPdfData($preData, DOMPDF_TEMP_DIR); } //Get the static information sheet $merger->addPdfData(file_get_contents("../View/Courses/survey_explanation.pdf"), DOMPDF_TEMP_DIR); if (!empty($postData)) { $merger->addPdfData($postData, DOMPDF_TEMP_DIR); } $merger->merge($download ? 'download' : 'browser'); } else { $dompdf->stream($name, array('Attachment' => $download)); } } catch (Exception $e) { $this->request->params['ext'] = 'html'; throw $e; } }