Easily generate PDF documents from HTML right inside of Laravel using this PDF wrapper. ZanySoft\LaravelPDF\PdfServiceProvider::class ] 'aliases' => [ //... 'PDF' => ZanySoft\LaravelPDF\Facades\PDF::class ] #configuration Configuration

use PDF; function generate_pdf() { $data = [ 'foo' => 'bar' ]; $pdf = PDF::::Make(); $pdf->loadView('pdf.document', $data); return $pdf->stream('document.pdf'); } or use ZanySoft\LaravelPDF\PDF; function generate_pdf() { $data = [ 'foo' => 'bar' ]; $pdf = new PDF(); $pdf->loadView('pdf.document', $data); return $pdf->stream('document.pdf'); }

$pdf->loadHTML($content); return $pdf->stream('document.pdf'); If you want to generate from files: $file = "file.txt" $pdf->loadFile($file); return $pdf->stream('document.pdf'); If you want download pdf file: return $pdf->embed('document.pdf'); If you want to save pdf to server: return $pdf->save('with-complete-path/document.pdf'); If you want add pdf file as attachment to email: return $pdf->embed('document.pdf'); #headers-and-footers Headers and Footers

use PDF; function generate_pdf() { $data = [ 'foo' => 'bar' ]; $pdf = PDF::Make(); $pdf->SetProtection(['copy', 'print'], 'user_pass', 'owner_pass') $pdf->loadView('pdf.document', $data); return $pdf->stream('document.pdf'); }
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners