infoway9/laravel-mpdf

Generate PDF document in Laravel framework with this mPDF wrapper.

v1.0.0 2019-01-14 09:38 UTC

This package is not auto-updated.

Last update: 2024-05-15 19:13:32 UTC


README

Generate PDF documents from raw HTML or laravel blade file using the laravel

Installation

Require this package in your composer.json or install it by running:

composer require infoway9/laravel-mpdf

Note: This package supports auto-discovery features of Laravel 5.4+, You only need to manually add the service provider and alias if working on Laravel version lower then 5.5

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

'providers' => [
	// ...
	Infoway\mPdf\mPdfServiceProvider::class
]
'aliases' => [
	// ...
	'PDF' => Infoway\mPdf\Facades\Pdf::class
]

Now, you should publish package's config file to your config directory by using following command:

php artisan vendor:publish --tag=laravel-mpdf

Basic Usage

This is the basic usage of this package.

<?php
namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use PDF;

class HomeController extends Controller {

    public function index() {
        $data = [
    		'foo' => 'bar'
    	];
        PDF::loadView('pdf',$data)->download('abc.pdf');
    }

}

Other methods

All available methods of pdf object are:

output(): Outputs the PDF as a string.
save($filename): Save the PDF to a file
download($filename): Make the PDF and download it. stream($filename): Return a response with the PDF to show in the browser.

License

Laravel PDF is open-sourced software licensed under the MIT license