Cakephp Email with PDF Attachment and PDF generation with CakePDF plugin
Step1: Installing and Setup CakePDF
Step 2: Configuration
Step 3: App Controller Configuration
App::uses('CakePdf', 'CakePdf.Pdf');
public $components = array("Email","RequestHandler");
Step 4: Controller Code for your CakePHP
// PDF Generation code
$this->set('extraparams', $categories);
$this->pdfConfig = array(
'orientation' => 'portrait',
'filename' => 'invoice_'. $orderID
);
$CakePdf = new CakePdf();
$CakePdf->viewVars(array('extraparams' => $categories));
$CakePdf->template('confirmpdf', 'default');
//get the pdf string returned
$pdf = $CakePdf->output();
//or write it to file directly
$pdf = $CakePdf->write(APP . 'webroot'. DS .'files' . DS . 'orders' . DS . 'order_'.$orderID.'.pdf');
$pdf = APP . 'webroot'. DS .'files' . DS . 'orders' . DS . 'order_'.$orderID.'.pdf';
// PDF Generation code
return $pdf;
Very helpful link, just follow mentioned steps and your PDF are generating:
Read More