PHP code example of jbreuer95 / laravel-make-pdf

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

    

jbreuer95 / laravel-make-pdf example snippets


return [
    // Configuration options will go here
];

use Breuer\MakePDF\Facades\PDF;

Route::get('/', function () {
    return PDF::view('view.name', [])->response();
});

return PDF::view('view.name', [])->download();

PDF::html('<h1>Hello World</h1>')

PDF::view('view.name', [])
    ->headerView('view.header')
    ->footerView('view.footer')
    ->response();

->headerHtml('<div>My header</div>')
->footerHtml('<div>My footer</div>')

use Breuer\MakePDF\Enums\Orientation;

PDF::landscape()

use Breuer\MakePDF\Enums\Format;

PDF::format(Format::A4)

use Breuer\MakePDF\Enums\Unit;

PDF::paperSize($height, $width)  // Uses inches by default
PDF::paperSize(29.7, 21, Unit::CENTIMETER)  // Uses centimeters and converts to inches

use Breuer\MakePDF\Enums\Unit;

PDF::margins($top, $right, $bottom, $left) // Uses inches by default
PDF::margins(2.54, 1.27, 2.54, 1.27, Unit::CENTIMETER)  // Centimeters, converted to inches

PDF::view('view.name', [])
    ->name('custom_filename')
    ->response();

->save('/path/to/save/yourfile.pdf')

$content = PDF::view('view.name', [])->raw();

->response()

->download()
bash
php artisan make-pdf:install