2017 © Pedro Peláez
 

library laravel-pdf

DOMPDF module for Laravel 5

image

vsmoraes/laravel-pdf

DOMPDF module for Laravel 5

  • Monday, August 21, 2017
  • by vsmoraes
  • Repository
  • 12 Watchers
  • 80 Stars
  • 56,980 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 28 Forks
  • 6 Open issues
  • 6 Versions
  • 15 % Grown

The README.md

pdf-laravel5

DOMPDF module for Laravel 5. Export your views as PDFs - with css support., (*1)

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Instalation

Add:, (*3)

"vsmoraes/laravel-pdf": "^2.0"

To your composer.json, (*4)

or Run:, (*5)

composer require vsmoraes/laravel-pdf

Then add:, (*6)

Vsmoraes\Pdf\PdfServiceProvider::class

To the providers array on your config/app.php, (*7)

And, (*8)

'PDF' => 'Vsmoraes\Pdf\PdfFacade',

To the aliases array on yout config/app.php in order to enable the PDF facade, (*9)

Usage

Route::get('/pdf/view', function() {
    $html = view('pdfs.example')->render();

    return PDF::load($html)->show();
});

Force download

Route::get('/pdf/download', function() {
    $html = view('pdfs.example')->render();

    return PDF::load($html)->download();
});

Return PDF as string

Route::get('/pdf/output', function() {
    $html = view('pdfs.example')->render();

    return PDF::load($html)
        ->output();
});

Set paper size and orientation

    Route::get('/pdf/output', function() {
        $html = view('pdfs.example')->render();

        return PDF::load($html, 'A4', 'landscape')
            ->output();
    });

Output to a file

Route::get('/pdf/output', function() {
    $html = view('pdfs.example')->render();

    PDF::load($html)
        ->filename('/tmp/example1.pdf')
        ->output();

    return 'PDF saved';
});

Inject on your controller

<?php namespace App\Http\Controllers;

use Vsmoraes\Pdf\Pdf;

class HomeController extends BaseControler
{
    private $pdf;

    public function __construct(Pdf $pdf)
    {
        $this->pdf = $pdf;
    }

    public function helloWorld()
    {
        $html = view('pdfs.example1')->render();

        return $this->pdf
            ->load($html)
            ->show();
    }
}

Configuration

Dompdf allows you to configure a bunch of things on your PDF file. In previous versions we used to accomplish this through environment vars, now you can change this configuration keys on the fly:, (*10)

Route::get('/pdf/view', function() {
    $html = view('pdfs.example')->render();

    $defaultOptions = PDF::getOptions();
    $defaultOptions->setDefaultFont('Courier');

    return PDF::setOptions($defaultOptions)->load($html)->download();
});

For the complete configuration reference: Dompdf options, (*11)

The Versions

21/08 2017

dev-master

9999999-dev

DOMPDF module for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel css html pdf dompdf html2pdf

06/07 2017

2.0

2.0.0.0

DOMPDF module for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel css html pdf dompdf html2pdf

12/01 2016

1.0.3

1.0.3.0

DOMPDF module for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel css html pdf dompdf html2pdf

11/01 2016

1.0.2

1.0.2.0

DOMPDF module for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel pdf dompdf

20/03 2015

1.0.1

1.0.1.0

DOMPDF module for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel pdf dompdf

17/03 2015

1.0

1.0.0.0

DOMPDF module for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel pdf dompdf