Question

I've generated a beautiful HTML invoice with MPDF, but when I placed it on the server it isn't showing anything.

The logs show the following for local (here the generation works):

http://pastebin.com/n3xJujBH

The logs show the following when generating on the server (here it shows an empty HTML page on generation, not PDF):

http://pastebin.com/HDeSPHse

The following code is used to generate the PDF in Codeigniter:

private function _gen_pdf($html,$paper='A4')
{
    $this->load->library('mpdf53/mpdf');

    $mpdf=new mPDF('utf-8',$paper);
    $mpdf->debug = true;
    $mpdf->WriteHTML($html);
    $mpdf->Output();
} 

The HTML created is following: http://pastebin.com/b3hFNbT8

Something to note is that, if I put only "test" in $html, it won't generate either.

Any ideas?

Was it helpful?

Solution 2

The answer for me was switching to DomPDF. I never got in functioning on the external parallels server and will probably never know why..

OTHER TIPS

This got me pass the obstacle

$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'tempDir' => __DIR__ . '/custom/tmp']);

Create custom (this can be anything) directory if it tells some permission error on the live server like on aws ubuntu instance etc...

I was facing the same issue.

I tried this code and it gave me the issue due to which mpdf was not working.

<?php

    // Require composer autoload
    require_once __DIR__ . '/vendor/autoload.php';
    
    try {
        $mpdf = new \Mpdf\Mpdf();
        $mpdf->debug = true;
        $mpdf->WriteHTML("Hello World");
        $mpdf->Output();
    } catch (\Mpdf\MpdfException $e) { // Note: safer fully qualified exception 
                                       //       name used for catch
        // Process the exception, log, print etc.
        echo $e->getMessage();
    }

?>

In my case i had to make the folder where i had kept my files writable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top