PHP code example of daandekker / laravel-chrome-pdf
1. Go to this page and download the library: Download daandekker/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/ */
use DaanDekker\ChromePdf\Facades\Pdf;
// From a Blade view
$pdf = Pdf::view('pdf.invoice', ['order' => $order]);
// From HTML string
$pdf = Pdf::html('<h1>Hello World</h1>');
// Download as attachment
return Pdf::view('pdf.invoice', $data)->download('invoice.pdf');
// Display inline in browser
return Pdf::view('pdf.invoice', $data)->stream('invoice.pdf');
// Save to file path
Pdf::view('pdf.invoice', $data)->save(storage_path('app/invoices/invoice.pdf'));
// Save to Laravel storage disk
Pdf::view('pdf.invoice', $data)->store('invoices/invoice.pdf', 's3');
// Get raw PDF content
$content = Pdf::view('pdf.invoice', $data)->output();