Permalink
Browse files

Added an option to output PDFs inline in the browser response (which …

…displays nicely inside the current tab in Chrome/ Safari but still acts as a download in Firefox)
  • Loading branch information...
1 parent 76cb149 commit 5ab10ed2502315d12dbc6134589a47c54d10d0c4 @vitch committed Jun 7, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 classes/view/mpdf/core.php
@@ -26,6 +26,15 @@ public function download($generated_filename, $view_file = NULL)
$mpdf->output($generated_filename, 'D');
}
+ public function inline($generated_filename, $view_file = NULL)
+ {
+ $mpdf = $this->get_mpdf($view_file);
+ $mpdf->output($generated_filename, 'I');
+ // Necessary to prevent Kohana from overriding the content-type set inside the previous function - we
+ // explictly set it to the correct type here...
+ Request::current()->headers[] = 'Content-type: application/pdf';
+ }
+
private function get_mpdf($view_file)
{
// Render the HTML normally

0 comments on commit 5ab10ed

Please sign in to comment.