PHP code example of chrisbraybrooke / laravel-chrome-pdf

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

    

chrisbraybrooke / laravel-chrome-pdf example snippets


ChrisBraybrooke\LaravelChromePdf\ServiceProvider::class,

'ChromePDF' => ChrisBraybrooke\LaravelChromePdf\ChromePDF::class,

namespace App\Http\Controllers;

use App\Invoice;
use ChromePDF;

class InvoicesController {

    /**
     * Download a PDF version of the invoice.
     *
     * @return void
     */
    public function show(Invoice $invoice)
    {
        // Load resources/views/invoice.blade.php
        ChromePDF::loadView('invoice', ['invoice' => $invoice])
            ->size('a4')
            ->landscape()
            ->download("invoice-{$invoice->ref}.pdf");
    }
}

ChromePDF::loadView('invoice', ['invoice' => $invoice])->download("invoice-{$ref}.pdf");

ChromePDF::loadView('invoice', ['invoice' => $invoice])->inline();

ChromePDF::loadView('invoice', ['invoice' => $invoice])->save("invoice-{$ref}.pdf", 's3');

ChromePDF::loadHtml('<h1>Hello world</h1>')->setOption('scale', '0.2')->download('hello.pdf');

ChromePDF::loadHtml('<h1>More options here!</h1>')
    ->setOptions(['scale' => 0.2, 'landscape'])
    ->download('options.pdf');

ChromePDF::loadHtml('<h1>Hello world</h1>')
    // a3 & a5 also available - pass true to set as landscape. Or use size('') and specify a different page size.
    ->a4()
    // Set the orientation as landscape - default is portrait.
    ->landscape()
    // Load a blade template for the page headers.
    ->headerView('default-header')
    // Load a blade template for the page footers.
    ->footerView('default-footer')
    ->download();
sh
/vendor/spiritix/php-chrome-html2pdf/node_modules/*