mPDF Library using Codeigniter

mPDF Library using Codeigniter

What is mPDF Library ?

mPDF library is a popular tool that is suitable for shared hosting users. By using this, they create and convert UTF-8 encoded HTML pages to PDF files. We can also say that these are PHP classes and HTML2PDF tools which purpose is the same – to create and manage PDF documents using simple PHP. In this article I am going to integrate mpdf library using Codeigniter.

mPDF Library using Codeigniter

CodeIgniter is one of the best PHP frameworks. In this topic, I will guide you that how to generate a PDF file by mPDF library using Codeigniter. There is three simple steps to do this. So, let’s start.

Namecheap.com

1- Create mpdf.php file

You can copy the below code and create the mpdf.php file. After that put it into the CodeIgniter library directory.

2- Download mPDF Library

mPDF can be downloaded from the following GitHub source or mpdf website. I will recommend download most recent library files from mpdf website After downloading, Extract it and put the mpdf folder into CodeIgniter third_party directory.

  1. Download mpdf Library
  2. Download mpdf Library from mpdf source

3- Creating the method for creating PDF from mPDF

Open Welcome Controller or make a new as per your requirement and then create a method on this controller as following

Here, my_ mPDF function of Welcome controller will generate pdf file of common/template view file.

It’s done. I hope it will help you.