This is how I integrated tcpdf and CI. First things first get your tcpfd class here. Extracted the following to the

system/plugins Folder

  • tcpdf/cache Folder
  • tcpdf/config Folder
  • tcpdf/fonts Folder (kind of big almost 9MB)
  • tcpdf/barcodes.php
  • tcpdf/htmlcolors.php
  • tcpdf/tcpdf.php
  • tcpdf/unicode_data.php

Hoping that I know what I’m doing and moved on in creating the tcpdf_pi.php and saved it to system/plugins Folder.

<?Php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	require_once('tcpdf/config/lang/eng.php');
	require_once('tcpdf/tcpdf.php');

	function tcpdf(){
		return new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
	}
?>

And on my controller I did this:

<?Php class Welcome extends Controller {
   function Welcome(){
      parent::Controller();
   }

   function index()
    {
    $this->load->plugin( 'tcpdf' );
    $pdf = tcpdf();

    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor("Nicola Asuni");
    $pdf->SetTitle("TCPDF Example 002");
    $pdf->SetSubject("TCPDF Tutorial");
    $pdf->SetKeywords("TCPDF, PDF, example, test, guide");
    // remove default header/footer
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    //set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);

    //set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 

    //initialize document
    $pdf->AliasNbPages();

    // add a page
    $pdf->AddPage();

    // ---------------------------------------------------------

    // set font
    $pdf->SetFont("dejavusans", "BI", 20);

    // print a line using Cell()
    $pdf->Cell(0,10,"Example 002",1,1,'C');

    // ---------------------------------------------------------

    //Close and output PDF document
    $pdf->Output("example_002.pdf", "I");
    }
}?>

A little bit of advice, this library has very little capability on converting HTML to PDF. DOMPDF still is my best bet.