PHPackages                             ambersive/documentviewer - 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. ambersive/documentviewer

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

ambersive/documentviewer
========================

Laravel package to create beautiful printable documents. We recommend the use with the ambersive/pdfprinter package to create documents.

v0.2.3(5y ago)142.6k1[3 PRs](https://github.com/sushidev-team/laravel-document-viewer/pulls)MITPHPCI failing

Since Jun 26Pushed 1y ago2 watchersCompare

[ Source](https://github.com/sushidev-team/laravel-document-viewer)[ Packagist](https://packagist.org/packages/ambersive/documentviewer)[ RSS](/packages/ambersive-documentviewer/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (5)Dependencies (7)Versions (9)Used By (0)

Document viewer
===============

[](#document-viewer)

The goal of this project is the attemp to provide a helper functionality for creating beautiful, printable and secure documents.

[![Maintainability](https://camo.githubusercontent.com/8bcf1f38ad6957597be3e302a8a04516ae8c450af8a91d0d3df1f9ff9a35999b/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f30663964323064613733313762353432356537322f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/AMBERSIVE/laravel-document-viewer/maintainability) [![Test Coverage](https://camo.githubusercontent.com/3fd7a656b65d794282c46f5419eb3e5e310610469221c752ea073e4451b86a2a/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f30663964323064613733313762353432356537322f746573745f636f766572616765)](https://codeclimate.com/github/AMBERSIVE/laravel-document-viewer/test_coverage)[![Build Status](https://camo.githubusercontent.com/130412e56d401a2ad4011e655ab6adb5f966418a82c44f295a088759f38bc9d3/68747470733a2f2f7472617669732d63692e6f72672f414d424552534956452f6c61726176656c2d646f63756d656e742d7669657765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/AMBERSIVE/laravel-document-viewer)

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

[](#installation)

```
composer require ambersive/documentviewer
```

Usage
-----

[](#usage)

### Step 1: Create a printable

[](#step-1-create-a-printable)

```
php artisan make:printable "Invoice"
```

### Step 2: Register the document viewer

[](#step-2-register-the-document-viewer)

Define a route in your desired router. Please be aware that default laravel middleware for web and api might require modifications there (eg for the post request).

```
$signed = false

Route::document(
    "invoices/{id}",
    "invoices",
    \App\Printables\Invoice::class,
    [
        // Middleware for getting the document
    ],
    $signed,
    \App\Printables\Invoice::class, // for file upload handling
    [
        // Middleware for postback / upload the document
    ]
);
```

The *signed* attribute will always be in effect for the get request of the document.

If you do not want a upload leave the upload class empty or null.

### Step 3: Modifiy the Class

[](#step-3-modifiy-the-class)

The command above will create *Printable* Class in the folder *Printable* within app\_path

First of all you should define data which is present or required in the specific blade file.

Then you should provide an uploadHandler. This will be required if you use our [Laravel Package for Print generation](https://github.com/AMBERSIVE/laravel-print-api) and the [Print-API](https://github.com/AMBERSIVE/print-api).

```
use Illuminate\Http\Request;

use AMBERSIVE\DocumentViewer\Abstracts\DocumentAbstract;

class Invoice extends DocumentAbstract
{

    public array $data   = [];

    // Define the blade you want to return as printable document
    public String $blade = "ambersive.documentviewer::printable_default";
    public bool  $useValidationEndpoint = false;

    public function setData(){
        // Request is available in $this->request
        // Save stuff in $this->data
        // This function must return $this (= chainable)
        // Params are provided in $this->params
        return $this;
    }

    public function uploadDocumentHandler(Request $request) {

        // Handle the file upload
        // Requires a response (preferable json)
        return ['status' => 200];

    }

    public function validateDocumentHandler(Request $request) {

        // Handle the validation
        // This information is a helper
        // Requires a response (preferable json)
        return ['status' => 200];

    }

}
```

### Step 4: Modify the blade file

[](#step-4-modify-the-blade-file)

The make command also creates a blade file within the resource folder. It will come with some basic scaffold settings so you will be able to create beautiful documents in no time.

If you want to create a custom blade file make sure you extend it with our base blade. Otherwise the enhanced view optimizations won't work.

```
@extends('ambersive.documentviewer::printable')
```

A full example might look like:

```
@extends('ambersive.documentviewer::printable')

@section('styles')

        body {
            // Custom Page style goes here
        }

@endsection

@section('document')

    Printable document

@endsection
```

Need a way to create PDF files?
-------------------------------

[](#need-a-way-to-create-pdf-files)

We created a [microservice](https://github.com/AMBERSIVE/print-api) which is also open-source to create pdf files. If you need a smooth way to interact with this microservice you can use our [package](https://github.com/AMBERSIVE/laravel-print-api) for that.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within this package, please send an e-mail to Manuel Pirker-Ihl via . All security vulnerabilities will be promptly addressed.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Total

5

Last Release

2051d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/80b1e9efacc425a65161eda871719db5a51d598f46e3afc5455009a889c1483a?d=identicon)[sushidev](/maintainers/sushidev)

---

Top Contributors

[![leganz](https://avatars.githubusercontent.com/u/3373530?v=4)](https://github.com/leganz "leganz (33 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

documentlaravelpdfpdfgenerator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ambersive-documentviewer/health.svg)

```
[![Health](https://phpackages.com/badges/ambersive-documentviewer/health.svg)](https://phpackages.com/packages/ambersive-documentviewer)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[elibyy/tcpdf-laravel

tcpdf support for Laravel 6, 7, 8, 9, 10, 11

3542.7M5](/packages/elibyy-tcpdf-laravel)[stevebauman/autodoc-facades

Auto-generate PHP doc annotations for Laravel facades

98186.6k9](/packages/stevebauman-autodoc-facades)[highsolutions/laravel-lang-import-export

A Laravel package providing artisan commands to import and export language files from and to CSV.

25292.3k](/packages/highsolutions-laravel-lang-import-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
