Generating a PDF in Codeigniter using mPDF

Hey, today I will show you integrating mPDF into CodeIgniter Application. mPDF is a PHP Class, by using this we can easily generate PDF files from HTML Templates.So styling PDF files as easy styling your HTML template as you wish.

Here is the updated post on CodeIgniter 3 – Using mPDF with CodeIgniter 3

Following are the simple steps to use mPDF with CodeIgniter.

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.

That is it. You had successfully integrated mPDF in CodeIgniter. Now let’s use it.

How to Use

Load the mPDF library just like your load other CI’s other libraries and then call pdf property. See the below example code for better understanding.

That’s it.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

Arjun
I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.
DMCA.com Protection Status