PHP code example of meeeet-dev / laravel-pdf
1. Go to this page and download the library: Download meeeet-dev/laravel-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/ */
meeeet-dev / laravel-pdf example snippets
'providers' => [
// ...
MeeeetDev\LaravelPdf\PdfServiceProvider::class
]
'aliases' => [
// ...
'PDF' => MeeeetDev\LaravelPdf\Facades\Pdf::class
]
use MeeeetDev\LaravelPdf\Facades\Pdf;
function generate_pdf() {
$data = [
'foo' => 'bar'
];
$pdf = Pdf::loadView('pdf.document', $data);
return $pdf->stream('document.pdf');
}
return [
'format' => 'A4', // See https://mpdf.github.io/paging/page-size-orientation.html
'author' => 'John Doe',
'subject' => 'This Document will explain the whole universe.',
'keywords' => 'PDF, Laravel, Package, Peace', // Separate values with comma
'creator' => 'Laravel Pdf',
'display_mode' => 'fullpage'
];
Pdf::loadView('pdf', $data, [], [
'format' => 'A5-L'
])->save($pdfFilePath);
$config = ['instanceConfigurator' => function($mpdf) {
$mpdf->SetImportUse();
$mpdf->SetDocTemplate(/path/example.pdf, true);
}]
Pdf::loadView('pdf', $data, [], $config)->save($pdfFilePath);
return [
// ...
'font_path' => base_path('resources/fonts/'),
'font_data' => [
'examplefont' => [
'R' => 'ExampleFont-Regular.ttf', // regular font
'B' => 'ExampleFont-Bold.ttf', // optional: bold font
'I' => 'ExampleFont-Italic.ttf', // optional: italic font
'BI' => 'ExampleFont-Bold-Italic.ttf' // optional: bold-italic font
//'useOTL' => 0xFF, //
use MeeeetDev\LaravelPdf\Facades\Pdf;
function generate_pdf() {
$data = [
'foo' => 'bar'
];
$pdf = Pdf::loadView('pdf.document', $data);
$pdf->SetProtection(['copy', 'print'], '', 'pass');
return $pdf->stream('document.pdf');
}
php artisan vendor:publish --provider="MeeeetDev\LaravelPdf\PdfServiceProvider"