CakePHP 3 – TCPDF Install and Usage

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->set('title', 'My Great Title');
          $this->set('file_name', '2016-06' . '_June_CLM.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 to create a pdf

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

1 Comment

  1. Andres

    Great, Thanks!


Submit a Comment

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

You May Also Like…

Toggen builds a new website

So I have built and hosted a new website for Roger Clark Pest Management they are a family owned and operated Pest...


Just downloaded WizTree (not a sponsor) from It seems to do what it says on the tin which is...

Scam call from “Telstra”

Just had a call from a man with a sub-continental accent from caller ID 0734946596 Told me there was problem with my...