Quick links: Content - sections - sub sections
EN FR

A jResponseTcpdf object allows you to generate a PDF and is based on the TCPDF class.

Download and Install

jResponseTcpdf is available in a separated module. You have to download the module jtcpdf and you have to install it like any other module.

You can install it with Composer: package jelix/tcpdf-module.

Declare the package jelix/tcpdf-module into your composer.json:


composer require "jelix/tcpdf-module"

Then configure the module and launch the installer:


  php dev.php module:configure jtcpdf
  php install/installer.php

Use it in a controller


  $resp = $this->getResponse('tcpdf');

  $resp->outputFileName = 'article.pdf';
  $resp->doDownload = true;

  // initialise l'objet tcpdf
  $resp->initPdf();
  $resp->tcpdf->AddPage();
  $resp->tcpdf->SetTitle('un titre');
  $resp->tcpdf->Text(10,10,'un texte');
  ...
  return $resp;

tcpdf member of the response is simply a TCPDF object (or an object which inherits from TCPDF). See TCPDF documentation about its use and its API.

If you want to override some tcpdf methods, you can use your own object. Example:


  $resp = $this->getResponse('tcpdf');

  $resp->outputFileName = 'article.pdf';
  $resp->doDownload = true;

  // initialize l'objet tcpdf
  $resp->tcpdf = new MyTcPdf();
  $resp->tcpdf->AddPage();
  $resp->tcpdf->SetTitle('un titre');
  $resp->tcpdf->Text(10,10,'un texte');
  ...
  return $resp;

MyTcPdf of course shall inherit from TCPDF or jTcpdf.