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