How to Generate PDFs in CodeIgniter with mPDF

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.

#codeigniter #mPDF

How to Generate PDFs in CodeIgniter with mPDF
1.00 GEEK