A PDF library for CodeIgniter that converts HTML content to PDFs. Uses the dompdf library
PHP C Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
application Move readme May 30, 2011
assets/pdfs Added email example May 30, 2011
README.markdown Move readme May 30, 2011



This is basically just a CI 2.0 wrapper for the dompdf library. Very basic functions at the moment, you can find an example controller in the files.


  1. Copy system/application/libraries/dompdf folder ()the whole thing) to your application/libraries folder
  2. Copy system/application/libraries/html2pdf.php to your application/libraries folder



There are 4 options you a required to set in order to create a PDF; folder, filename, paper and HTML

//Load the library

//Set folder to save PDF to

//Set the filename to save/download as

//Set the paper defaults
$this->html2pdf->paper('a4', 'portrait');

//Load html view
$this->html2pdf->html(<h1>Some Title</h1><p>Some content in here</p>);

The create function has two options 'save' and 'download'. Save will just write the PDF to the folder you choose in the settings. Download will force the PDF to download in the clients browser.

//Create the PDF

Advanced usage

Theres no reason why you can't build and pass a view to the html() function. Also note the create() function will return the saved path if you choose the 'save' option.

$data = array(
    'title' => 'PDF Created',
    'message' => 'Hello World!'

//Load html view
$this->html2pdf->html($this->load->view('pdf', $data, true));

if($path = $this->html2pdf->create('save')) {
    //PDF was successfully saved or downloaded
    echo 'PDF saved to: ' . $path;

Emailing a PDF

You can use the path returned by the create() function to email the PDF using the CI email class

if($path = $this->html2pdf->create('save')) {


    $this->email->from('your@example.com', 'Your Name');

    $this->email->subject('Email PDF Test');
    $this->email->message('Testing the email a freshly created PDF');   





  • 0.1 - Got up and running with GitHub