Welcome Guest, Not a member yet? Register   Sign In
TCPDF with CodeIgniter
#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');
  }
}


Messages In This Thread
TCPDF with CodeIgniter - by El Forum - 03-17-2013, 03:22 AM
TCPDF with CodeIgniter - by El Forum - 03-19-2013, 02:31 PM
TCPDF with CodeIgniter - by El Forum - 07-05-2013, 11:41 PM
TCPDF with CodeIgniter - by El Forum - 07-07-2013, 03:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB