DOM PDF INTEGRATION IN CAKEPHP

Step 1 : Download Dompdf lib from dompdf site,

Step 2 : Dompdf lib put into cakephp app/vendors directory

Step 3 : Create your function into your controller for run dompdf.

 

 

<?php

 

function example()

{

 

App::import(‘Vendor’, ‘dompdf’, array(‘file’ => ‘dompdf’ . DS . ‘dompdf_config.inc.php’));

$html =
‘<html><body>’.
‘<p>Put your html here, or generate it with your favourite ‘.
‘templating system.</p>’.
‘</body></html>’;

$this->dompdf = new DOMPDF();
$papersize = “legal”;
$orientation = ‘landscape’;
$this->dompdf->load_html($html);
$this->dompdf->set_paper($papersize, $orientation);
$this->dompdf->render();

$output = $this->dompdf->output();
file_put_contents(‘Brochure.pdf’, $output);

 

}

 

?>