Question

I just installed CakePdf to produce PDF file. I would like to use Mpdf engine instead of WkHtmlToPdf.

I have already add public $components = array('RequestHandler'); in my FormsController controller file. Also I've already created the layouts and view files like so app/View/Layouts/pdf/default.ctp and app/View/Forms/pdf/view.ctp.

The following is how I create my code:

<?php
// the rest of the codes

public function view($id=null) {
  $kid = $this->FormU5mrn->find('first', array(
    'conditions' => array('FormU5mrn.id' => $id),
  ));

  $filename = 'U5MR-' . $kid['FormU5mrn']['ref_no'] . '.pdf';

  $this->pdfConfig = array(
    'orientation' => 'portrait',
    'filename' => $filename
  );

  $this->set(compact('kid'));
}

I get the following errors:

Notice (8): Undefined index: BODY [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 14242]
Notice (8): Undefined index: BODY>>ID>> [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 14288]
Notice (8): Undefined offset: -1 [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 14421]
Notice (8): Undefined property: mPDF::$hasOC [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 27777]
Notice (8): Undefined property: mPDF::$hasOC [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 27879]
Notice (8): Undefined property: mPDF::$hasOC [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 8772]
Was it helpful?

Solution

Change the debug value from 1/2 -> 0 in app/Config/core.php

Configure::write('debug', 0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top