TCPDF Cakephp 3


i am experimenting on TCPDF on Cakephp 3 without using plugins, i saw the following link on the setting up, but not able to understand the following parts

what is means where to call Vendor class at Controller, ?
in controller using TCPDF library by calling vendor class.
require_once(ROOT . DS . ‘vendor’ . DS . ‘TCPDF’ . DS . ‘tcpdf.php’);

Declare page Size

define instant of Tcpdf class and setup page size 350 X 250 . using l for landscape pdf page. using UTF-8 for using Persian words.

$width = 350;
$height = 200;
$pageLayout = array( $height , $width); // or array($height, $width)
$pdf = new \TCPDF(‘l’, ‘pt’, $pageLayout, true, ‘UTF-8’, false);

remove header and footer

I want to make some kind of invoice that print on package so remove the footer and header of pdf.


Set some language dependent data:

$lg = Array();
$lg[‘a_meta_charset’] = ‘UTF-8’;
$lg[‘a_meta_dir’] = ‘rtl’;
$lg[‘a_meta_language’] = ‘fa’;
$lg[‘w_page’] = ‘page’;


Set a font:

// set font
$pdf->SetFont(‘dejavusans’, ‘’, 12);
$pdf->SetAutoPageBreak(true, 0);

add a page:


write Text:

$text = “گیرنده :” . $variable[‘user’][‘name’];

// Persian and English content
$pdf->WriteHTML($text, true, 0, true, 0);

// set LTR direction for english translation


next Line:


Make pdf file:

$pdf->Output(‘test.pdf’, ‘I’);

im confused with the explanation, or is there a more detailed version on how to set up TCPDF tutorial to recommend?

thanks :smiley: