CodeIgniter Forums
TCPDF with CodeIgniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: TCPDF with CodeIgniter (/showthread.php?tid=57470)



TCPDF with CodeIgniter - El Forum - 03-17-2013

[eluser]Unknown[/eluser]
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

http://www.amplio.ch/blog/web-development/tcpdf-in-codeigniter/

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

Thanks in advance


TCPDF with CodeIgniter - El Forum - 03-19-2013

[eluser]bgreene[/eluser]
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
Code:
# override the default TCPDF config file
/* commented out by bill 21apr 2011
if(!defined('K_TCPDF_EXTERNAL_CONFIG')) {
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
}
*/
# include TCPDF
require(APPPATH.'config/tcpdf_ci'.EXT);
require_once($tcpdf['base_directory'].'tcpdf.php');

then to use it, i have a reports controller which has procedures like
Code:
function showtrolley(){
  $this->load->library('pdf');

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

  $this->pdf->reportinit();
  // FreeSans, DejaVuSans, Helvetica, PDFAHelvetica, Arial, Born, Frutiger
  // $ix = 11;
  //$this->pdf->SetFont($this->pdf->installedfonts[$ix]);
  $this->pdf->SetFont('PDFAHelvetica','',9);

  //$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');

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



TCPDF with CodeIgniter - El Forum - 07-05-2013

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

Quote:http://www.php-guru.in/2013/html-to-pdf-conversion-in-codeigniter/



TCPDF with CodeIgniter - El Forum - 07-07-2013

[eluser]Ckirk[/eluser]
I'm a fan of DOMPDF I've used it on a few projects