PHP code example of donnykurnia / l5mpdf

1. Go to this page and download the library: Download donnykurnia/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/ */

    

donnykurnia / l5mpdf example snippets


'Servit\Mpdf\ServiceProvider',

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

$router->get('/pdf/view', function() {
    $pdf = \App::make('mpdf.wrapper', [
        'mode'   => 'id+aCJK',
        'format' => 'A4-L',
    ]);
    $pdf->WriteHTML('<h1>Page 1</h1>');
    $pdf->AddPage('P');
    $pdf->WriteHTML('<h1>Page 2</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';
});

[
    'mode'                  => '',
    'format'                => 'A4',
    'defaultFontSize'       => '',
    'defaultFont'           => '',
    'marginLeft'            => 10,
    'marginRight'           => 10,
    'marginTop'             => 10,
    'marginBottom'          => 10,
    'marginHeader'          => 10,
    'marginFooter'          => 5,
    'orientation'           => 'P',
]