Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 12 revisions

I struggled some some strange nuances on the other TCPDF-CI integration, so I thought that I would just post some notes on how I got it working in a very simple and easy manner.

  1. Download TCPDF - http://sourceforge.net/projects/tcpdf/files/

  2. Unzip the above download into /application/libraries/tcpdf. Make sure that the main tcpdf.php file is in this directory

  3. Create a new file: /application/libraries/Pdf.php:

[code]<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once dirname(FILE) . '/tcpdf/tcpdf.php';

class Pdf extends TCPDF { function __construct() { parent::__construct(); } }

?> /* End of file Pdf.php / / Location: ./application/libraries/Pdf.php */ [/code]

  1. To create a new PDF you would do something like this in your controller: [code] $this->load->library('Pdf');

$pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->SetTitle('My Title'); $pdf->SetHeaderMargin(30); $pdf->SetTopMargin(20); $pdf->setFooterMargin(20); $pdf->SetAutoPageBreak(true); $pdf->SetAuthor('Author'); $pdf->SetDisplayMode('real', 'default');

$pdf->Write(5, 'Some sample text)); $pdf->Output('My-File-Name.pdf, 'I'); [/code]

Clone this wiki locally