Extension for Kohana's View class that renders as a PDF instead of HTML. Uses MPDF to render normal HTML views as PDF Files.
If your application is a Git repository:
git submodule add git://github.com/smgladkovskiy/kohana-mpdf.git modules/mpdf
git submodule update --init --recursive
Or clone the the module separately:
cd modules
git clone git://github.com/smgladkovskiy/kohana-mpdf.git mpdf
cd modules/mpdf
git submodule update --init
Edit application/bootstrap.php
and add a the module:
Kohana::modules(array(
...
'mpdf' => 'modules/mpdf',
...
));
Placed in a controller action:
// Load a view using the PDF extension
$pdf = View_MPDF::factory('pdf/example');
// Use the PDF as the request response
$this->response->body($pdf);
// Force download
$pdf->download('brochure.pdf');
// Set the PDF footer (every page) using directly the MPDF object
$pdf->get_mpdf()->SetHTMLFooter('<p>Footer disclaimer</p>');