Reputation: 1591
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):
The logs show the following when generating on the server (here it shows an empty HTML page on generation, not PDF):
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?
Upvotes: 1
Views: 3382
Reputation: 101
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...
Upvotes: 1
Reputation: 119
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.
Upvotes: 0
Reputation: 1591
The answer for me was switching to DomPDF. I never got in functioning on the external parallels server and will probably never know why..
Upvotes: 0