2017 © Pedro Peláez
 

library pdf

dompdf for Laravel 4

image

thujohn/pdf

dompdf for Laravel 4

  • Tuesday, December 2, 2014
  • by thujohn
  • Repository
  • 16 Watchers
  • 233 Stars
  • 160,390 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 69 Forks
  • 69 Open issues
  • 8 Versions
  • 3 % Grown

The README.md

Dompdf

Simple Dompdf package for Laravel 4 This package uses the latest stable version (0.5), (*1)

Build Status, (*2)

Installation

Run, (*3)

composer require thujohn/pdf

OR, (*4)

Add thujohn/pdf to composer.json., (*5)

"thujohn/pdf": "dev-master"

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

Now open up app/config/app.php and add the service provider to your providers array., (*7)

'providers' => array(
    'Thujohn\Pdf\PdfServiceProvider',
)

Now add the alias., (*8)

'aliases' => array(
    'PDF' => 'Thujohn\Pdf\PdfFacade',
)

Publish the config, (*9)

php artisan config:publish thujohn/pdf

Usage

Show a PDF, (*10)

Route::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, (*11)

Route::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, (*12)

Route::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, (*13)

for ($i=1;$i<=2;$i++)
{
    $pdf = new \Thujohn\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, (*14)

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

02/12 2014

dev-master

9999999-dev

dompdf for Laravel 4

  Sources   Download

MIT

The Requires

 

by Avatar thujohn

laravel pdf laravel4 dompdf

02/12 2014

1.0.6

1.0.6.0

dompdf for Laravel 4

  Sources   Download

MIT

The Requires

 

by Avatar thujohn

laravel pdf laravel4 dompdf

13/11 2013

1.0.5

1.0.5.0

dompdf for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel pdf laravel4 dompdf

11/10 2013

1.0.4

1.0.4.0

dompdf for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel pdf laravel4 dompdf

05/08 2013

1.0.3

1.0.3.0

dompdf for Laravel 4

  Sources   Download

MIT

The Requires

 

laravel pdf laravel4 dompdf

31/07 2013

1.0.2

1.0.2.0

dompdf for Laravel 4

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

laravel pdf laravel4 dompdf

16/07 2013

1.0.1

1.0.1.0

dompdf for Laravel 4

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

laravel pdf laravel4 dompdf

23/06 2013

1.0.0

1.0.0.0

dompdf for Laravel 4

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

laravel pdf laravel4 dompdf