PHPackages                             iamproperty/print - 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. iamproperty/print

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

iamproperty/print
=================

Document printing like Laravel's Mail package

0.2.1(6y ago)5116MITPHPPHP ^7.3

Since Oct 10Pushed 11mo ago2 watchersCompare

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

READMEChangelogDependencies (5)Versions (4)Used By (0)

Printer
=======

[](#printer)

- [Introduction](#introduction)
    - [Installation](#installation)
- [Writing Printables](#writing-printables)
    - [Configuring The View](#configuring-the-view)
    - [View Data](#view-data)
- [Rendering Printables](#rendering-printables)
    - [Previewing Printables In The Browser](#previewing-printables-in-the-browser)

Introduction
------------

[](#introduction)

Printer provides a way to render PDFs using an API similar to [Laravel's Mailable](https://laravel.com/docs/mail).

### Installation

[](#installation)

```
$ composer require iamproperty/print
```

Writing Printables
------------------

[](#writing-printables)

All of a printable class' configuration is done in the `build` method. Within this method, you may call the methods `view`, and `with` to configure the view to be printed.

### Configuring The View

[](#configuring-the-view)

Within a printable class' `build` method, you may use the `view` method to specify which template should be used when rendering the document's contents. Since each document typically uses a [Blade template](https://laravel.com/docs/blade) to render its contents, you have the full power and convenience of the Blade templating engine when building your document's HTML:

```
/**
 * Build the document.
 *
 * @return $this
 */
public function build()
{
    return $this->view('printed.orders.invoice');
}

```

### View Data

[](#view-data)

#### Via Public Properties

[](#via-public-properties)

Typically, you will want to pass some data to your view that you can utilize when rendering the document's HTML. There are two ways you may make data available to your view. First, any public property defined on your printable class will automatically be made available to the view. So, for example, you may pass data into your printable class' constructor and set that data to public properties defined on the class:

```
