April 01, 2015

In this article, we are going to discuss about How to install PDF generator library for CodeIgniter and How to use PDF generator library in CodeIgniter. CodeIgniter is an open source rapid development web application framework, for use in building dynamic web sites with PHP.

CodeIgniter is loosely based on the popular Model-View-Controller development pattern. While controller classes are a necessary part of development under CodeIgniter, models and views are optional.

Installation

  1. Drop the pdf.php library into your libraries directory.
  2. Download domPDF from http://code.google.com/p/dompdf/downloads/list
  3. Drop the dompdf directory into your libraries directory alongside the pdf.php file.

Usage

You can convert a view into a PDF by using the following code.

$this->load->library('pdf');
$this->pdf->load_view('welcome');
$this->pdf->render();
$this->pdf->stream("welcome.pdf");

You can also pass in data to the function just as you would using $this->load->view('welcome', $data); by using

$this->pdf->load_view('welcome', $data);

0 comments:

Post a Comment