DomPDF Library using Codeigniter

DomPDF Library using Codeigniter

What is DomPDF?

Simply, it is an HTML to PDF converter. It is a great library and can create a PDF from HTML markup and CSS styles (it’s mostly CSS 2.1 compliant and has support for some CSS3 properties). We can control our content structure. So, the final PDF document will be as per our requirements. It will contain the styles and etc. Soit is a CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is also a style-driven render-er: it will read  inline style tags, and the style attributes of individual HTML elements. In this article I ma going to implement DomPDF Library using Codeigniter.

DomPDF 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 DomPDF library using Codeigniter . There is three simple steps to do this. So, let’s start.

1- Download pdf.php file

Download it from Download pdf.php file or you can copy the below code and create the pdf.php file. After that put it into the CodeIgniter library directory.


2- Download DomPDF Library

DomPDF can be downloaded from two sources. After downloading, Extract it and put the dompdf folder into CodeIgniter library directory.


3- Creating the method for creating PDF from DOMPDF

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

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

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