Search code examples
phpmpdffat-free-framework

Can't use MPDF with Fat-free framework


I've this piece of code working in a .php file

include('assets/plugins/mpdf57/mpdf.php');
$mpdf=new mPDF('win-1252','A4','','',20,15,48,25,10,10); 
$mpdf->useOnlyCoreFonts = true;
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("The title");
$mpdf->SetAuthor('Test');
$mpdf->SetWatermarkText('Test');
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$mpdf->showImageErrors = true;
$mpdf->WriteHTML('Hi');
//$mpdf->Output();
$mpdf->Output('tmp/testo.pdf','F');

It creates a pdf file file with the word 'Hi' in it. But when I copypaste this code to my Fat-free route function, it doesn't work. And it's not an include path mistake.

function pdf($f3){
    //SAME CODE
}

How am I supposed to use external libraries (and mpdf) using the Fat-free php framework? Thanks!


Solution

  • Already fixed it, seems like there's some kind of error reporting coming from the mpdf library that Fat-free framework doesn't accept.

    Adding this at the top solved everything

    error_reporting(0);