Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install mpdf 7 without composer?

Tags:

mpdf

I'm currently using mpdf 6.1 and I'd like to switch to 7. But I can't find a way to install it without composer. Is there a full package that I can download, unzip and test on my localhost?

like image 325
LuBre Avatar asked May 10 '18 20:05

LuBre


People also ask

How can I use mPDF without composer?

2) Ensure all needed classes are loaded This means both mPDF classes and dependencies classes. You can do this manually (reload, find the file with missing class, add require call, repeat) or you can use some autoloading library.

How do I know which version of mPDF I have?

make sure both your PHP version in console and in the server environment is supported. Checking phpinfo(); often does not suffice, try inserting var_dump(PHP_VERSION); die; right before your mPDF code to find actual PHP version used with mPDF.

What is mPDF file?

mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF (see CREDITS), with a number of enhancements. mPDF was written by Ian Back and is released under the GNU GPL v2 licence.


1 Answers

well, i've spend few days to search a way, finally i found it, you can download full package mpdf in this site, after download extract files and place on your project and load 'vendor/autoload.php'. in my case i use it with codeigniter, so i make some php file on libraries folder to load it.

<?php 
if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class M_pdf 
{ 
    function __construct()
    { 
        include_once APPPATH.'libraries\vendor\autoload.php'; 
    } 
    function pdf()
    { 
        $CI = & get_instance(); 
        log_message('Debug', 'mPDF class is loaded.'); 
    } 
    function load($param=[])
    { 
        return new \Mpdf\Mpdf($param); 
    } 
}

after that i use it on my controller file :

$this->load->library('M_pdf');
$mpdf = $this->m_pdf->load([
   'mode' => 'utf-8',
   'format' => 'A4'
]);

$mpdf->WriteHTML("Hello World!");
$mpdf->Output();

but i still recommend to use composer as well,

like image 118
Mas Karebet Avatar answered Oct 09 '22 04:10

Mas Karebet