2017 © Pedro Peláez
 

library laravel-dompdf

Generate PDFs in Laravel with this mPDF wrapper.

image

danielfnz/laravel-dompdf

Generate PDFs in Laravel with this mPDF wrapper.

  • Friday, January 20, 2017
  • by danielfnz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 65 Forks
  • 0 Open issues
  • 37 Versions
  • 0 % Grown

The README.md

Laravel PDF: mPDF wrapper for Laravel 5

Easily generate PDF documents from HTML right inside of Laravel using this mPDF wrapper., (*1)

Installation

Require this package in your composer.json or install it by running:, (*2)

composer require niklasravnsborg/laravel-pdf

To start using Laravel, add the Service Provider and the Facade to your config/app.php:, (*3)

'providers' => [
    // ...
    niklasravnsborg\LaravelPdf\PdfServiceProvider::class
]
'aliases' => [
    // ...
    'PDF' => niklasravnsborg\LaravelPdf\Facades\Pdf::class
]

Basic Usage

To use Laravel PDF add something like this to one of your controllers. You can pass data to a view in /resources/views., (*4)

use PDF;

function generate_pdf() {
    $data = [
        'foo' => 'bar'
    ];
    $pdf = PDF::loadView('pdf.document', $data);
    return $pdf->stream('document.pdf');
}

Config

You can use a custom file to overwrite the default configuration. Just create config/pdf.php and add this:, (*5)

return [
    'mode'                 => '',
    'format'               => 'A4',
    'default_font_size'    => '12',
    'default_font'         => 'sans-serif',
    'margin_left'          => 10,
    'margin_right'         => 10,
    'margin_top'           => 10,
    'margin_bottom'        => 10,
    'margin_header'        => 0,
    'margin_footer'        => 0,
    'orientation'          => 'P',
    'title'                => 'Laravel mPDF',
    'author'               => '',
    'watermark'            => '',
    'show_watermark'       => false,
    'watermark_font'       => 'sans-serif',
    'display_mode'         => 'fullpage',
    'watermark_text_alpha' => 0.1
];

Headers and Footers

If you want to have headers and footers that appear on every page, add them to your <body> tag like this:, (*6)

<htmlpageheader name="page-header">
    Your Header Content
</htmlpageheader>

<htmlpagefooter name="page-footer">
    Your Footer Content
</htmlpagefooter>

Now you just need to define them with the name attribute in your CSS:, (*7)

@page {
    header: page-header;
    footer: page-footer;
}

Inside of headers and footers {PAGENO} can be used to display the page number., (*8)

Included Fonts

By default you can use all the fonts shipped with mPDF., (*9)

Custom Fonts

You can use your own fonts in the generated PDFs. The TTF files have to be located in one folder, e.g. /resources/fonts/. Add this to your configuration file (/config/pdf.php):, (*10)

return [
    'custom_font_path' => base_path('/resources/fonts/'), // don't forget the trailing slash!
    'custom_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
        ]
        // ...add as many as you want.
    ]
];

Now you can use the font in CSS:, (*11)

body {
    font-family: 'examplefont', sans-serif;
}

Set Protection

To set protection, you just call the SetProtection() method and pass an array with permissions, an user password and an owner password., (*12)

The passwords are optional., (*13)

There are a fews permissions: 'copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres'., (*14)

use PDF;

function generate_pdf() {
    $data = [
        'foo' => 'bar'
    ];
    $pdf = PDF::loadView('pdf.document', $data);
    $pdf->SetProtection(['copy', 'print'], '', 'pass');
    return $pdf->stream('document.pdf');
}

Find more information to SetProtection() here: https://mpdf.github.io/reference/mpdf-functions/setprotection.html, (*15)

License

Laravel PDF is open-sourced software licensed under the MIT license, (*16)

The Versions

20/01 2017

dev-master

9999999-dev

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

17/01 2017

dev-fix

dev-fix

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

12/01 2017

v1.4.3

1.4.3.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

12/01 2017

v1.4.2

1.4.2.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

30/12 2016

v1.4.1

1.4.1.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

26/12 2016

v1.4.0

1.4.0.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

26/12 2016

v1.3.0

1.3.0.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

23/12 2016

v1.2.0

1.2.0.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

21/12 2016

v1.1.4

1.1.4.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

20/12 2016

v1.1.3

1.1.3.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

30/08 2016

v1.1.2

1.1.2.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

17/08 2016

v0.7.0

0.7.0.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

23/04 2016

v1.1.1

1.1.1.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

23/04 2016

v1.1.0

1.1.0.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

23/04 2016

v1.0.0

1.0.0.0

Generate PDFs in Laravel with this mPDF wrapper.

  Sources   Download

MIT

The Requires

 

laravel pdf mpdf

21/12 2015

v0.6.1

0.6.1.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

11/06 2015

v0.6.0

0.6.0.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

11/06 2015

0.5.x-dev

0.5.9999999.9999999-dev

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

11/06 2015

v0.5.2

0.5.2.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

25/05 2015

v0.5.1

0.5.1.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

04/02 2015

0.4.x-dev

0.4.9999999.9999999-dev

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

04/02 2015

v0.5.0

0.5.0.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

20/08 2014

v0.4.6

0.4.6.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

13/08 2014

v0.4.5

0.4.5.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

14/07 2014

v0.4.4

0.4.4.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

02/07 2014

v0.4.3

0.4.3.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

02/07 2014

v0.4.2

0.4.2.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

02/07 2014

v0.4.1

0.4.1.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

01/07 2014

v0.4.0

0.4.0.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

22/03 2014

v0.3.1

0.3.1.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

13/02 2014

v0.3.0

0.3.0.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

31/01 2014

v0.2.3

0.2.3.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

15/11 2013

v0.2.2

0.2.2.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

22/10 2013

v0.2.1

0.2.1.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

01/08 2013

v0.2.0

0.2.0.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

29/07 2013

v0.1.1

0.1.1.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf

23/06 2013

v0.1.0

0.1.0.0

A DOMPDF Wrapper for Laravel

  Sources   Download

MIT

The Requires

 

laravel pdf dompdf