Written by James McDonald

May 30, 2016

In your CakePHP top level folder (the one that has composer.json, src/, vendors/, config/, webroot/) run:

composer require tecnickcom/tcpdf

You should now have vendor/tecnickcom/tcpdf

Now in a controller src/Controller/<ControllerName>Controller.php create an action:

public function pdfView($schedule_id = null){
        
          $this->viewBuilder()->layout('ajax');
          $this->set('title', 'My Great Title');
          $this->set('file_name', '2016-06' . '_June_CLM.pdf');
         $this->response->type('pdf');

}

Then create a view in src/Template/<ControllerName>/pdf_view.ctp

class xtcpdf extends TCPDF {

}


$pdf = new xtcpdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// use the examples at http://tcpdf.org to create a pdf


$pdf->Output($file_name, 'I');

1 Comment

  1. Andres

    Great, Thanks!

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...