PHPackages                             takeoo/zend-pdf - 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. takeoo/zend-pdf

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

takeoo/zend-pdf
===============

Create pdf from view in zend framework 2

v0.2.1(9y ago)04.1kPHP

Since Mar 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/TakeoO/zend-pdf)[ Packagist](https://packagist.org/packages/takeoo/zend-pdf)[ RSS](/packages/takeoo-zend-pdf/feed)WikiDiscussions master Synced yesterday

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

HTML to PDF for zend framework
==============================

[](#html-to-pdf-for-zend-framework)

Create pdf from view in ZendFramework 3

Works on zend framework v3.\*

IF you want to use it with older versions, use one of previous tags

Requirements
------------

[](#requirements)

- wkhtmltopdf installed on your server

    - Debian, Ubuntu:

    ```
    sudo apt-get install wkhtmltopdf
    ```

    - \*Debian servers have known errors with wkhtmltopdf lib, so if you get error like:

    ```
    wkhtmltopdf: cannot connect to X server
    ```

    install xvfb:

    ```
    sudo apt-get install xvfb
    ```
- zend-view 2.3\* is installed as dependency
- zend-service-manager is already installed with 3.\* version of zf3.

Install
-------

[](#install)

- Composer install

    ```
     composer require takeoo/zend-pdf
    ```
- Add "Takeoo\\Pdf" to 'modules' array in application.config.php

Usage
-----

[](#usage)

- Takeoo\\Zend-pdf will create service throughout service manager, so it is available in serviceLocator as 'PdfCreator';
- Instantiate:

```
$pdfCreator = $serviceManager->get('PdfCreator');
```

**NOTE:** PdfCreator is not shared service, so every call to serviceManager will create new instance.

PdfCreator uses ViewResolver which is auto-magically injected to PhpRenderer if have MVC application, so you can use any view or layout you have in your app!

- Set layout

    ```
     $pdfCreator->setLayoutTemplate('layout/pdf-template');
    ```

    - Add view as you would in your response, just pass name and variables to *createHtml()* function

    ```
    $pdfCreator->createHtml('path/to/view', ['variableName' => $variableValue]);
    ```

    OR you can directly pass already created view model

    ```
    $pdfCreator->createHtmlFromViewModel($viewModel);
    ```
- Output

    - All modern browser support pdf output directly to browser:

        ```
        $pdfCreator->output();
        ```
    - get file handle

        ```
        $pdfCreator->writePdf();
        ```

    **NOTE:** Both above functions will save file to your disk
- Get file path

    ```
    $pdfCreator->getFilePath();
    ```
- By default all files are generated to your project root into "{Ymd\_His}.pdf"
- Change file destination

    ```
    $pdfCreator->setPdfFileName('path/to/desired/folder/nameofyourfile.pdf');
    ```

**NOTE:** All functions with public scope (with exception of output() and writePdf()) are fluent, so you can chain all functions:

```
$pdfCreator->setLayoutTemplate('layout/pdf-layout')
  ->createHtml('view', ['variable1' => $variable1Value])
  ->setPdfFileName('./../file.pdf')
  ->setHasXvfb(false)
  ->output();
```

**NOTE:** By default all wkhtmltopdf conversions are created with *setHasXvfb(true)*, so you have to have installed **Xvfb** on your server! If you want to turn it of just do:

```
$pdfCreator->setHasXvfb(false);
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~15 days

Total

4

Last Release

3345d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8413270?v=4)[Jan Mrhar](/maintainers/TakeoO)[@TakeoO](https://github.com/TakeoO)

---

Top Contributors

[![TakeoO](https://avatars.githubusercontent.com/u/8413270?v=4)](https://github.com/TakeoO "TakeoO (19 commits)")

### Embed Badge

![Health badge](/badges/takeoo-zend-pdf/health.svg)

```
[![Health](https://phpackages.com/badges/takeoo-zend-pdf/health.svg)](https://phpackages.com/packages/takeoo-zend-pdf)
```

###  Alternatives

[qipsius/tcpdf-bundle

A bundle to easily integrate TCPDF into Symfony

23749.5k](/packages/qipsius-tcpdf-bundle)[macopedia/magmi2

Magento Mass Importer 'Magmi' for Magento 2

11615.7k](/packages/macopedia-magmi2)[tarfin-labs/easy-pdf

Makes pdf processing easy.

1719.4k](/packages/tarfin-labs-easy-pdf)

PHPackages © 2026

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