/** * Processes a template file using dompdf (LGPL). * * @param Zikula_View $view Reference to view object. * @param string $template Name of template to use. * * @return mixed Output. */ protected function processPdf(Zikula_View $view, $template) { // first the content, to set page vars $output = $view->fetch($template); // make local images absolute $output = str_replace('img src="/', 'img src="' . System::serverGetVar('DOCUMENT_ROOT') . '/', $output); // see http://codeigniter.com/forums/viewthread/69388/P15/#561214 //$output = utf8_decode($output); // then the surrounding $output = $view->fetch('include_pdfheader.tpl') . $output . '</body></html>'; $controllerHelper = new Reviews_Util_Controller($this->serviceManager); // create name of the pdf output file $fileTitle = $controllerHelper->formatPermalink(System::getVar('sitename')) . '-' . $controllerHelper->formatPermalink(PageUtil::getVar('title')) . '-' . date('Ymd') . '.pdf'; // if ($_GET['dbg'] == 1) die($output); // instantiate pdf object $pdf = new \DOMPDF(); // define page properties $pdf->set_paper('A4'); // load html input data $pdf->load_html($output); // create the actual pdf file $pdf->render(); // stream output to browser $pdf->stream($fileTitle); // prevent additional output by shutting down the system System::shutDown(); return true; }