This article will explain, how to create a pdf file using mpdf from html / php. Install php if you are working on local ubuntu machine, on shared hosting mostly php will have been installed.
Below command will install php5 on Ubuntu [ Note: this article mentions steps as followed on Ubuntu 14.04 which was latest stable Ubuntu version at the time of writing this article , please use updated versions as required and are available ]
$ sudo apt-get install php5
If you are using ubuntu 16.04, it comes with php7, which we can install using below steps,
$ sudo apt-get install libapache2-mod-php
$ sudo apt-get install php-mbstring
Download mpdf code from website,
$ cd /var/www/html
$ git clone https://github.com/lynxbee/mpdf.git
Here, we will try to create a sample example in localhost, so we will need to move this code to localhost,
$ vim mpdfexample.php
$ vim mpdfexample.php
<?php
include("mpdf/mpdf.php");
$mpdf = new mPDF();
$mpdf->WriteHTML('<h1>Hello world!</h1>');
$mpdf->Output();
?>
Now, open this php file at localhost in browser as,
http://localhost/mpdfexample.php