Welcome Guest, Not a member yet? Register   Sign In
TCPDF with CodeIgniter

Hi guys. I'm somewhat new to CodeIgniter framework. So I need a big help from you all. Is there a way in CodeIgniter to create PDF files. If not how can I integrate TCPDF library with CodeIgniter? I tried several ways including this


but nothing got worked for me. I'm using CodeIgniter latest version. Please help me to get through this.

Thanks in advance

tcpdf works fine for me. I installed it into libraries/tcpdf with pdf.php in libraries. The only change I made was in pdf.php as follows, its up at the top of the file. make sure ci_application/pdf cache is 777
# override the default TCPDF config file
/* commented out by bill 21apr 2011
if(!defined('K_TCPDF_EXTERNAL_CONFIG')) {
# include TCPDF

then to use it, i have a reports controller which has procedures like
function showtrolley(){

  // set document information
  $this->pdf->SetAuthor('Klee Paper');
  $this->pdf->SetTitle('Order Preparation - Not yet sent');
  $this->pdf->SetSubject('Order in Progress');

  // FreeSans, DejaVuSans, Helvetica, PDFAHelvetica, Arial, Born, Frutiger
  // $ix = 11;

  //$this->pdf->Write(0,'Date: '.date("Y-m-d H:i:s", $data['main']['transdate']));
  //etc etc etc
  //etc etc etc
               // finally
               $filename = 'order_prep'.date("YmdHis", time()) .'.pdf';

  if ($asfile == TRUE) {
   $filepath = APPPATH.'pdfcache/'; // codeigniter/application/pdfcache
   $fullname = $filepath . $filename;
   $this->pdf->Output($fullname, 'F');

   $data = file_get_contents($fullname);
   force_download($filename, $data);
  } else {
   return $this->pdf->Output($filename, 'I');

We can also use helper of TCPDF library and generate PDF in CodeIgniter, please check the link for the same


I'm a fan of DOMPDF I've used it on a few projects

Theme © iAndrew 2016 - Forum software by © MyBB