1. Go to this page and download the library: Download igeek/pdfservice 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 Igeek\PdfService\Facades\Pdf;
// Generate and save a PDF
Pdf::view('pdf.invoice', ['invoice' => $invoice])
->save('invoices/invoice-001.pdf');
// Generate and download
return Pdf::view('pdf.invoice', ['invoice' => $invoice])->download('invoice.pdf');
// Display inline in browser
return Pdf::view('pdf.invoice', ['invoice' => $invoice])->inline('invoice.pdf');
Pdf::html('<h1>Hello World</h1><p>This is a PDF.</p>')
->save('hello.pdf');
Pdf::view('pdf.content', $data)
->headerView('pdf.header', ['title' => 'My Report'])
->footerView('pdf.footer')
->save('report.pdf');
// Or with raw HTML
Pdf::view('pdf.content', $data)
->headerHtml('<div style="text-align: center;">Header</div>')
->footerHtml('<div style="text-align: center;">Page @pageNumber of @totalPages</div>')
->save('report.pdf');
use Igeek\PdfService\Enums\Format;
// Using enum
Pdf::view('pdf.content', $data)
->format(Format::Letter)
->save('letter.pdf');
// Using string
Pdf::view('pdf.content', $data)
->format('legal')
->save('legal.pdf');
Pdf::view('pdf.content', $data)
->size([8.5, 14]) // Custom size in inches
->save('custom.pdf');