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
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::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/*
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.