PHPackages                             websolutionstuff/pdf-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. websolutionstuff/pdf-laravel

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

websolutionstuff/pdf-laravel
============================

Websolutionstuff PDF support for Laravel 6, Laravel 7, Laravel 8, Laravel 9

1.0(3y ago)112MITPHP

Since Dec 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/websolutionstuff/pdf-laravel)[ Packagist](https://packagist.org/packages/websolutionstuff/pdf-laravel)[ RSS](/packages/websolutionstuff-pdf-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Laravel 6-7-8-9 HTML To PDF Converter
=====================================

[](#laravel-6-7-8-9-html-to-pdf-converter)

[![Latest Stable Version](https://camo.githubusercontent.com/3ea873d5d460381b786fd8b136be0d16beedb57f50c9b2ef8bb1591632b20450/687474703a2f2f706f7365722e707567782e6f72672f776562736f6c7574696f6e73747566662f7064662d6c61726176656c2f76)](https://packagist.org/packages/websolutionstuff/pdf-laravel) [![Total Downloads](https://camo.githubusercontent.com/aec05fe959bd0dfbff09b71ffce149d5cccd042ec0501ee15c8bc97ec4b1dc7b/687474703a2f2f706f7365722e707567782e6f72672f776562736f6c7574696f6e73747566662f7064662d6c61726176656c2f646f776e6c6f616473)](https://packagist.org/packages/websolutionstuff/pdf-laravel) [![License](https://camo.githubusercontent.com/08d242bd4b1d19c0154f0f5f67856a1116019beac1f0a68398e198f02c489e41/687474703a2f2f706f7365722e707567782e6f72672f776562736f6c7574696f6e73747566662f7064662d6c61726176656c2f6c6963656e7365)](https://packagist.org/packages/websolutionstuff/pdf-laravel)

Installation
------------

[](#installation)

The Laravel PDF service provider can be installed via [composer](http://getcomposer.org) by requiring the `websolutionstuff/pdf-laravel` package in your project's `composer.json` file.

```
composer require websolutionstuff/pdf-laravel

```

or

Laravel 5.5+ will use the auto-discovery function.

```
{
    "require": {
        "websolutionstuff/pdf-laravel": "^1.0"
    }
}
```

If you don't use auto-discovery you will need to include the service provider and facade in the `config/app.php` file.

```
'providers' => [
    ...
    ...
    Websolutionstuff\PDF\ServiceProvider::class
]

//...

'aliases' => [
    ...
    ..
    'PDF' => Websolutionstuff\PDF\Facades\PDF::class
]
```

Lumen
-----

[](#lumen)

In the Lumen add the following lines:

```
$app->register(Websolutionstuff\PDF\ServiceProvider::class);
class_alias(Websolutionstuff\PDF\Facades\PDF::class, 'PDF');
```

Example
-------

[](#example)

Let's see some beautiful examples.

```
use PDF; // at the top of the file

  PDF::SetTitle('Websolutionstuff PDF File');
  PDF::AddPage();
  PDF::Write(0, 'Websolutionstuff PDF File Generate');
  PDF::Output('websolutionstuff.pdf');
```

another example for generating multiple PDF's

```
use PDF; // at the top of the file

  for ($i = 0; $i < 5; $i++) {
    PDF::SetTitle('Websolutionstuff PDF File'.$i);
    PDF::AddPage();
    PDF::Write(0, 'Websolutionstuff PDF File Generate'.$i);
    PDF::Output(public_path('websolutionstuff' . $i . '.pdf'), 'F');
    PDF::reset();
  }
```

#### Example 1: Add HTML Text

[](#example-1-add-html-text)

```
        $html = 'Hello World';

        PDF::SetTitle('Hello World');
        PDF::AddPage();
        PDF::writeHTML($html, true, false, true, false, '');
        PDF::Output('Example_1.pdf');
```

#### Example 2: without Header and Footer

[](#example-2-without-header-and-footer)

```
        // remove default header/footer
        PDF::setPrintHeader(false);
        PDF::setPrintFooter(false);

        // set margins
        PDF::SetMargins(20,20,20);

        // set auto page breaks
        PDF::SetAutoPageBreak(TRUE, 20);

        // set font
        PDF::SetFont('times', 'BI', 20);

        // add a page
        PDF::AddPage();

        // set some text to print
        $txt =
