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

[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-developmen...deigniter/

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

Thanks in advance
#2

[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');
  }
}
#3

[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-...deigniter/
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB