How To Create Pdf Using MPDF Codeigniter 3?

In my previous post, We wrote a article on CodeIgniter 3 PDF Generate Tutorial With Example and in that article We covered mPDF library manual installation step by step, without any types of the run composer. So in this post, We would like to use CodeIgniter 3 as well as composer to install and to load mPDF library.

Here are the simple 5 steps to generate main PDF in the CodeIgniter 3 web application with mPDF: also resolve Error “temporary files directory is not writable mpdf codeigniter”.

Step 1:

first of all you can simple Download and install CodeIgniter.

Also Read: PHP Create PDF file using mpdf

Step 2:

and then Run below composer command to download mPDF library from your web project Directory. It will make a fresh Directory called “vendor” as well as it will download free “mpdf” library into it.

Also Read This πŸ‘‰   how to install tar.gz in ubuntu?

$ composer require mpdf/mpdf

there is my the directory main step 3 and step 4 after installing mpdf

Step 3:

Open application/config/config.php file as well as update you vendor directory path

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

Also Read: PHP How-to create Dynamic PDF Files using FPDF

Step 4:

Use mPDF library inside in your controller, here is the sample:

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('html_to_pdf',[],true);
		$mpdf->Output(); // opens in browser
		//$mpdf->Output('pakainfo.pdf','D'); // it downloads the file into the user system, with give name


Free Live Chat for Any Issue

Step 5:

simple last step to create a view called html_to_pdf.php file in server side in your view Directory with below html part.

<!DOCTYPE html>
<html lang="en">
	<meta charset="utf-8">
	<title>Welcome to pakainfo</title>

<div id="container">
	<h2>Welcome to pakainfo!</h2>

	<div id="body">
		<p>If you have not found Tamilrockers website worth or have not liked by pakainfo.</p>

		<p>TamilRockers New Link: Want to know the way to get Tamilrockers New link ? or Tamilrockers Latest URL?</p>

		<p>tamilrockers new website</p>

		<p>TamilRockers New Website 2020.. how to download tamilrockers new link without using any VPN applications enter tamil rockers domain <a href="user_guide/">tamilrockers new link</a>.</p>



Also Read: Laravel 7 Generate/Create PDF File Tutorial From Scratch

Also Read This πŸ‘‰   Laravel 6 Clear Queued Jobs Example

Step 6:

That’s it. Very quick and simple. Now access your CodeIgniter application, you should get similar results:

Rate this post