How to generate pdf in Codeigniter using MPDF Library

How to generate pdf in Codeigniter using MPDF Library

In this article, we will discuss How to generate pdf in Codeigniter using the mPDF library. There are many packages available but mPDF package through we can easily generate the pdf file.

Why do we need to pdf file? when we need to generate the invoice, booking ticket generate, large data convert into pdf invoice and many more things. in case we need to pdf file.

There are many packages available but mPDF Library package through we can easily generate pdf in Codeigniter using the mPDF library.

Download and install Codeigniter

We are going to install Codeigniter 3, first, we will download a fresh Codeigniter 3 version and install it in our system. so you can follow below Link for Download CodeIgniter.

Download Mpdf Library

Now, We will Download the Mpdf package Library using the below composer command.

Configurations of a vendor directory path

In this step, We will set the vendor directory path in the “application/config/config.php” file. so you can see the below code.

Create Controller

In this step, we will create a Mypdf.php file in the “application/controller” directory and paste the below code in this controller.

Create View File

So finally, we can create another file in and pass some data from the database to the “application/views/” directory. but here we are using simple files like “application/views/welcome_message.php”.
application/views/welcome_message.php

Please follow and like us: