参考Generating a PDF in Codeigniter using mPDF
1.Download and extract mPDF
Download mPDF from : http://www.mpdf1.com/mpdf/index.php and Extract it to your application/third_party/ folder of your CodeIgniter.
Create a new file in your application/libraries/ name it M_pdf.php and copy past the blow PHP Script.1
2
3
4
5
6
7
8
9
10
11
12
13
14if (!defined('BASEPATH')) exit('No direct script access allowed');
include_once APPPATH.'/third_party/mpdf/mpdf.php';
class M_pdf {
public $param;
public $pdf;
public function __construct($param = '"UTF-8","A4","","",10,10,10,10,6,3')
{
$this->param =$param;
//$this->pdf = new mPDF($this->param);
$this->pdf = new mPDF('+aCJK','A4','','',32,25,27,25,16,13);
$this->pdf->autoLangToFont = true;
}
}
That is it. You had successfully integrated mPDF in CodeIgniter. Now let’s use it.
2.Edit config.php
edit the application/third_party/mpdf/config.php
line44:1
$this->useAdobeCJK = true;
line67:1
$this->autoLangToFont = true;
3.How to Use
Load the mPDF library just like your load other CI’s other libraries and then call pdf property. See the blow example code for better understanding.
1 | if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |