Convert HTML to PDF in CodeIgniter using Dompdf

Convert HTML to PDF in CodeIgniter using Dompdf

Nowadays PDF is the most used format in various web applications. There are multiple libraries like TCPDF, Snappy, mPDF etc can be used to create PDF in a web application. DomPDF is one of the most popular libraries to convert your data into PDF. Here are very easy steps to create HTML to PDF:

We are using default views/welcome_message.php with controller/welcome.php to generate pdf that is easy to understand. You can add your model & include it into the controller.

Step 1: Download DOMPDF from here. Paste it into application\libraries folder
Step 2: Create a file name named Pdf.php into application\libraries folder and paste below code.

Step 3 : Now create an controller that renders html view to PDF.

Step 4 :In above controller we have used default welcome.php, you can replace with YOUR_VIEW.php file. Create a model if you are using custom view in step4 and load it into controller.

That’s it your rendered html in view file will looks like above image. Check it by http://YOUR_SITE_URL/welcome/generatepdf

So this is How to Convert HTML to PDF in CodeIgniter using Dompdf, If you are looking to create a unique, feature-rich and error-free web application development then you need to hire a dedicated developer from Techcompose Solutions who work solely on your project who will make sure your project is developed within the time frame and it meets your business requirement. Our Developers are experienced and had executed several small to complex development projects. We strictly believe in proper communication at the beginning which makes sure that your requirement is totally understood and we both are in the right track. Our developers know very well what your business may require to enable you to stand out in competition. Contact us to hire dedicated developers for developing a project on Codeigniter or you can reach us at

Urjit Rajgor

Leave a reply

Your email address will not be published. Required fields are marked *

Do You Have Any Interesting Project In Mind? Let`s Discuss