PHP code example of maspriyono / l5mpdf

1. Go to this page and download the library: Download maspriyono/l5mpdf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maspriyono / l5mpdf example snippets


'Servit\Mpdf\ServiceProvider',

'PDF'     => 'Servit\Mpdf\Facades\Pdf',

$router->get('/pdf/view', function() {
       // Config::set('mpdfconfig.pdf.options',['th','A5','','',10,10,10,10,10,5,'L'] );
       // Config::set('mpdfconfig.pdf.options','"th","A0","","",10,10,10,10,6,3');
       // $mpdfcfg = Config::get('mpdfconfig');
       // dump($mpdfcfg);
       // consolelog('mpdfcfg1',$mpdfcfg);
       $pdf = \App::make('mpdf.wrapper',['th','A0','','',10,10,10,10,10,5,'L']);
       // $pdf = \App::make('mpdf.wrapper');
       $pdf->WriteHTML('<h1>test</h1>');
       $pdf->AddPage('P');
       $pdf->WriteHTML('<h1>test2</h1>');
       $pdf->stream();
});

$router->get('/pdf/download', function() {
    $html = view('pdfs.example')->render();

    return PDF::load($html)->download();
});

$router->get('/pdf/output', function() {
    $html = view('pdfs.example')->render();

    PDF::load($html)
        ->filename('/tmp/example1.pdf')
        ->output();

    return 'PDF saved';
});