How to Convert an Image to PDF in CodeIgniter using FPDF Library

In this article, You will learn about how to create pdf file in Codeigniter from image using fpdf library . PDF is the most used format to generate PDF for image document in the web application. PDF file provides a easy and user-friendly way to upload the bunch of records in a pdf format file. If you are working on Codeigniter then you get problem to how to do it. But in this post i am going to share you very simple example to image to pdf convert using FPDF library.

FPDF is a PHP library that helps to generate PDF file from image file. It’s very easy to convert an image to PDF in codeignniter with fpdf.

Step 1: Download Fresh Codeigniter 3

In First step we need to download fresh version of Codeigniter 3, After Download successfully, extract clean new Codeigniter 3 application.

so if you haven’t download yet then download from here : Download Codeigniter 3.

Step 2: Download fpdf library

 let’s download fpdf library from here : Click Here to download fpdf. After download, extract it to your “application/libraries” folder and rename it to “fpdf”.

Step 3: Create mypdf.php file in “application/libraries” Folder

Create mypdf.php file in “application/libraries” folder and copy and paste the following code in this file

Step 4: Add Controller Method

In this step we require to add “imagetopdf” method on welcome controller, So let’s add with following code. you have to just copy of welcome.php controller file:

application/controllers/Welcome.php

Step 5: Add View File

Now at last step we require to create “imagetopdf.php” view file for generate pdf file.  So you have to copy below code and create on view folder:

application/views/imagetopdf.php

Now you can open bellow URL on your browser:

http://localhost:8000/welcome/imagetopdf

If you are on live sever:

 http://domainname.com/welcome/imagetopdf

How to Convert HTML to PDF in CodeIgniter using Dompdf Library

How to Generate PDF from Mysql Database using PHP

Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request

Related posts