PHP code example of razvan171514 / pdf-gen

1. Go to this page and download the library: Download razvan171514/pdf-gen 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/ */

    

razvan171514 / pdf-gen example snippets


...
'aliases' => [
    ...
    'Pdf' => razvan\PdfGen\Pdf::class,
    ...
],
...

return [
    /** mpdf , dompdf*/
    'driver' => 'dompdf',
    'dompdf_config' => [
        'page' => 'A4',
        /** landscape, portrait */
        'orientation' => 'portrait',
    ],
    /** path to template directoy */
    'templates_path' => __DIR__ . '/../resources/views/',
    /** path to output directory */
    'output_path' => __DIR__ . '/../resources/views/pdfs/',
];

...
'templates_path' => base_path('resources/views'),
'output_path' => base_path('resources/views/pdfs'),
...

Pdf::generate('file_name.html', [
    'name' => 'oputput_file_name.pdf',
    'mode' => 'F',
]);

...
use razvan\PdfGen\Pdf;
...
// html template
Pdf::generate('file_name.html', ['name' => 'some_other_name.pdf']);
// markdown template
Pdf::generate('file_name.md', ['mode' => 'D']);
// view
Pdf::generate(view('blade_view'));
// view with data
Pdf::generate(view('blade_view', compact('data')), [
    'name' => 'cool_name.pdf',
    'mode' => 'D',
]);
config/app.php
config/pdf.php
bash
$ php artisan vendor:publish --provider="razvan\PdfGen\PdfServiceProvider"
config/pdf.php
file.pdf
config/app.php