Quick links: Content - sections - sub sections
EN FR

a jResponseTcpdf object allows you to generate a PDF and is based on the TCPDF class (which enhances the famous FPDF).

Download and Install

jResponseTcpdf requires fonts to work. Those are downloadable from jelix.org website here (As the fonts package weighs big, it is not bundled with jelix package). Download and install them in lib/pdf-fonts/.

Use it in an action


  $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.