2017 © Pedro Peláez
 

library lum-pdf

compatibility fork of k98kurz/pdf-lumen (dompdf wrapper) for Laravel Lumen

image

azakur4/lum-pdf

compatibility fork of k98kurz/pdf-lumen (dompdf wrapper) for Laravel Lumen

  • Monday, June 20, 2016
  • by Azakur4
  • Repository
  • 1 Watchers
  • 0 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 69 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Dompdf

Compatibility conversion of k98kurz/pdf-lumen for Laravel Lumen 5.* Simple Dompdf wrapper package (uses Dompdf stable version 0.5), (*1)

By: Azakur4/lum-pdf, (*2)

Installation

Add azakur4/lum-pdf to composer.json., (*3)

"azakur4/lum-pdf": "dev-master"

Run composer update to pull down the latest version of Pdf., (*4)

Now open up bootstrap/app.php and add the service provider., (*5)

    $app->register('azakur4\Pdf\PdfServiceProvider');

Now add the alias., (*6)

    class_alias('azakur4\Pdf\PdfFacade', 'PDF');

Configuration

Copy the default configuration file from the config folder of this project to your application root config folder dompdf.php, (*7)

Now open up bootstrap/app.php and add this line:, (*8)

   $app->configure('dompdf');

Usage

Show a PDF, (*9)

$app->get('/', function () {
    $html = '<html><body>'
            . '<p>Put your html here, or generate it with your favourite '
            . 'templating system.</p>'
            . '</body></html>';
    return PDF::load($html, 'A4', 'portrait')->show();
});

Download a PDF, (*10)

$app->get('/', function () {
    $html = '<html><body>'
            . '<p>Put your html here, or generate it with your favourite '
            . 'templating system.</p>'
            . '</body></html>';
    return PDF::load($html, 'A4', 'portrait')->download('my_pdf');
});

Returns a PDF as a string, (*11)

$app->get('/', function () {
    $html = '<html><body>'
            . '<p>Put your html here, or generate it with your favourite '
            . 'templating system.</p>'
            . '</body></html>';
    $pdf = PDF::load($html, 'A4', 'portrait')->output();
});

Multiple PDFs, (*12)

for ($i=1;$i<=2;$i++) {
    $pdf = new \k98kurz\Pdf\Pdf();
    $content = $pdf->load(View::make('pdf.image'))->output();
    File::put(public_path('test'.$i.'.pdf'), $content);
}
PDF::clear();

Examples

Save the PDF to a file in a specific folder, and then mail it as attachement. By @w0rldart, (*13)

define('BUDGETS_DIR', public_path('uploads/budgets')); // I define this in a constants.php file

if (!is_dir(BUDGETS_DIR)){
    mkdir(BUDGETS_DIR, 0755, true);
}

$outputName = str_random(10); // str_random is a [Laravel helper](http://laravel.com/docs/helpers#strings)
$pdfPath = BUDGETS_DIR.'/'.$outputName.'.pdf';
File::put($pdfPath, PDF::load($view, 'A4', 'portrait')->output());

Mail::send('emails.pdf', $data, function($message) use ($pdfPath){
    $message->from('us@example.com', 'Laravel');
    $message->to('you@example.com');
    $message->attach($pdfPath);
});

The Versions

20/06 2016

dev-master

9999999-dev

compatibility fork of k98kurz/pdf-lumen (dompdf wrapper) for Laravel Lumen

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jimmy Brian Anamaria Torres

laravel lumen pdf dompdf

20/06 2016

1.0.0

1.0.0.0

compatibility fork of k98kurz/pdf-lumen (dompdf wrapper) for Laravel Lumen

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jimmy Brian Anamaria Torres

laravel lumen pdf dompdf