content_type='application/pdf'; } public function header($r, $print = TRUE) { $r->html = ''; } public function render($r, $format, $options = array()) { // To Do // The option switch off links on PDF will bee good here too $disable_links = variable_get('forena_pdf_disable_links', TRUE); $skin_data = Frx::Data()->getContext('skin'); $page_data = isset($skin_data['mpdf']['page']) ? $skin_data['mpdf']['page'] : array('orientation' => 'P'); $html = $r->html; if ($disable_links) { $html = preg_replace('/(.*?)<\/a>/', "\\2", $html); } $mpdf = new mPDF('UTF-8'); $mpdf->AddPageByArray($page_data); $output = ''; $output .= ''; $css = ''; foreach (Frx::Skin()->stylesheets as $type => $sheets) { foreach ($sheets as $sheet) { switch ($type) { case 'all': case 'print': case 'screen': case 'pdf': if (strpos($sheet, 'http:') === 0 || strpos($sheet, 'https:') === 0) { $output .= " \n"; } else { $css .= file_get_contents($sheet); } //echo $sheet; break; } } } if (@$options['css'] || isset($r->rpt_xml->head->style)) { $output .= ''; } $output .= '' . $r->title . "

" . $r->title . '

' . $html; $output .= ''; $mpdf->WriteHTML($output); // $pdf = $mpdf->Output('', 'S'); $filename = basename($_GET['q']); $pdf = $mpdf->Output($filename, 'I'); return $pdf; } public function output(&$output) { $http_headers = array( 'Pragma' => 'no-cache', 'Expires' => '0', 'Cache-Control' => 'no-cache, must-revalidate', 'Cache-Control' => 'private', 'Content-Transfer-Encoding' => 'binary', 'Content-Type' => 'application/pdf', ); foreach ($http_headers as $name => $value) { $value = preg_replace('/\r?\n(?!\t| )/', '', $value); drupal_add_http_header($name, $value); } return TRUE; } }