how to generate pdf using mpdf in codeigniter?

Today, We want to share with you how to generate pdf using mpdf in codeigniter?.In this post we will show you mpdf library for php 7, hear for export data to pdf in codeigniter we will give you demo and example for implement.In this post, we will learn about generate pdf in PHP with an example.

how to generate pdf file from database in codeigniter?

Using mPDF with CodeIgniter 3

$ composer require mpdf/mpdf


 $config['composer_autoload'] = 'vendor/autoload.php';

Use mPDF library inside in your controller

defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
 public function index()
 $mpdf = new \Mpdf\Mpdf();
 $html = $this->load->view('generated_pdf_file',[],true);
 $mpdf->Output(); // opens in browser

create a view called generated_pdf_file.php

<!DOCTYPE html>
<html lang="en">
 <meta charset="utf-8">
 <title>Welcome to</title>
<div id="container">
 <h2>Welcome to Pakainfo!</h2>
 <div id="body">
 <p>TamilRockers is a very popular Indian torrent website where you will get a collection of unlimited Tamil and Bollywood movies.</p>
 <p>Because tamilrockers website is blocked by the telecommunications authorities of India(ISP) to prevent movie piracy. I will be updating regularly. </p>
 <p>TamilRockers. TamilRockers is a public torrent website. TamilRockers website uploads the pirated versions of Tamil, Telugu, Hindi, English, ...</p>

 <p> <a href="">tamilrockers new domain</a>.</p>

I hope you get an idea about Generating a PDF in Codeigniter using mPDF.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.