PHPackages                             littlerocket/pdf-bundle - 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. littlerocket/pdf-bundle

ActiveSymfony-bundle[PDF &amp; Document Generation](/categories/documents)

littlerocket/pdf-bundle
=======================

This bundle integrates Symfony with PHPPdf library. Fork to fix the bundle for usage with PHP7

1.1.1(3y ago)02.0k1MITPHPPHP &gt;=7.1

Since Aug 23Pushed 1y agoCompare

[ Source](https://github.com/littlerocketdev/PdfBundle)[ Packagist](https://packagist.org/packages/littlerocket/pdf-bundle)[ RSS](/packages/littlerocket-pdf-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (6)Used By (0)

PsPdfBundle
===========

[](#pspdfbundle)

This bundle integrates Symfony2 with [PHPPdf](https://github.com/littlerocketdev/PHPPdf) library. Thanks to this bundle you can easily generate PDF or image (png, jpg) files.

Documentation of [PHPPdf](https://github.com/littlerocketdev/PHPPdf) you can find on github (README file).

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

[](#installation)

1. Use composer. PsPdfBundle requires "minimum-stability" equals to dev. Run this command:

    composer require littlerocket/pdf-bundle
2. Register bundle in AppKernel:

    ```
     //app/AppKernel.php
     public function registerBundles()
     {
         return array(
             // ..
             new Ps\PdfBundle\PsPdfBundle(),
             // ..
         );
     }

    ```

Configuration
-------------

[](#configuration)

All options are optional.

```
# app/config/config.yml
ps_pdf:
    nodes_file: ~
    fonts_file: ~
    complex_attributes_file: ~
    colors_file: ~
    use_cache_in_stylesheet: ~
    cache:
      type: ~
      options: ~
    markdown_stylesheet_filepath: ~
    markdown_document_template_filepath: ~
    document_parser_type: ~

```

- nodes\_file - path to file with nodes/tags definitions, internal nodes.xml file from PHPPdf library is used by default
- fonts\_file - path to file with fonts definitions, internal fonts.xml file from PHPPdf library is used by default
- complex\_attributes\_file - path to file with complex attributes definitions, internal complex-attributes.xml file from PHPPdf library is used by default
- colors\_file - path to file with default palette of colors, internal colors.xml file from PHPPdf library is used by default
- cache.type - type of cache, supported are all backend cache from Zend\_Cache component (for instance File, Apc, Memcached, Sqlite etc.). File engine is used by default.
- cache.options - specyfic options for cache engine (for instance "cache\_dir" for File engine). cache\_dir by default is as same as kernel.cache\_dir.
- use\_cache\_in\_stylesheet - stylesheet maching rules will be cache, if this option is set. In complex stylesheet cache significantly improves performance. Default is true, but **in dev environment cache should be off**.
- markdown\_stylesheet\_filepath - filepath of stylesheet for markdown parser
- markdown\_document\_template\_filepath - xml document template form output of markdown parser
- document\_parser\_type - default parser type: xml or markdown

Images in source document
-------------------------

[](#images-in-source-document)

If you want to display image, you must provide absolute path to image file via "src" attribute of image tag. Asset Twig function dosn't work, because it converts image path to relative path according to web directory. To make using of images easier, bundle provides Twig function, that converts image logical name to real, absolute path.

Example:

```

```

Bundle based paths in fonts and document xml file
-------------------------------------------------

[](#bundle-based-paths-in-fonts-and-document-xml-file)

If you want to use custom fonts, you should create your own fonts.xml config file (default fonts filepath is PHPPdf\\Resources\\config\\fonts.xml). To make easier defining fonts paths, bundle based paths are supported. Example:

```

```

"%SomeBundle:file.ttf%" will be replaced by "path/to/SomeBundle/Resources/file.ttf"

Example
-------

[](#example)

```
// In controller
//...
use Ps\PdfBundle\Annotation\Pdf;
//...

/**
 * @Pdf()
 */
public function helloAction($name)
{
    $format = $this->get('request')->get('_format');

    return $this->render(sprintf('SomeBundle:SomeController:helloAction.%s.twig', $format), array(
        'name' => $name,
    ));
}

// in helloAction.html.twig
Hello {{ name }}!

// in helloAction.pdf.twig

        Hello {{ name }}!

```

Bundle automatically detects pdf format (via \_format) request and create pdf document from response.

Pdf annotation has four optional properties:

- headers - associative array of specyfic headers
- stylesheet - pdf stylesheet template file in standard Symfony2 notation ("Bundle:Controller:file.format.engine")
- documentParserType - type of parser: xml or markdown
- enableCache - pdf output should by cached? True or false, default: false. Hash (md5) from template and stylesheet content is a cache key, only PHPPdf invocation is cached, controller is always called.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.2% 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 ~77 days

Total

4

Last Release

1129d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce6b7981172eda87151031f80bc6b10440ecfcee5ab406b90fb7666675acba36?d=identicon)[littlerocket](/maintainers/littlerocket)

---

Top Contributors

[![psliwa](https://avatars.githubusercontent.com/u/438063?v=4)](https://github.com/psliwa "psliwa (83 commits)")[![DaanLR](https://avatars.githubusercontent.com/u/167091964?v=4)](https://github.com/DaanLR "DaanLR (3 commits)")[![Ghkuijer](https://avatars.githubusercontent.com/u/1204636?v=4)](https://github.com/Ghkuijer "Ghkuijer (1 commits)")[![gido](https://avatars.githubusercontent.com/u/101859?v=4)](https://github.com/gido "gido (1 commits)")[![marphi](https://avatars.githubusercontent.com/u/57309?v=4)](https://github.com/marphi "marphi (1 commits)")[![mcg-web](https://avatars.githubusercontent.com/u/1496283?v=4)](https://github.com/mcg-web "mcg-web (1 commits)")[![phansys](https://avatars.githubusercontent.com/u/1231441?v=4)](https://github.com/phansys "phansys (1 commits)")[![soullivaneuh](https://avatars.githubusercontent.com/u/1698357?v=4)](https://github.com/soullivaneuh "soullivaneuh (1 commits)")[![doppynl](https://avatars.githubusercontent.com/u/814475?v=4)](https://github.com/doppynl "doppynl (1 commits)")

---

Tags

pdfPHPPdf

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/littlerocket-pdf-bundle/health.svg)

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

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

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

TCPDF is a PHP class for generating PDF documents and barcodes.

4.5k101.8M473](/packages/tecnickcom-tcpdf)[mpdf/mpdf

PHP library generating PDF files from UTF-8 encoded HTML

4.7k77.1M493](/packages/mpdf-mpdf)[knplabs/knp-snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.

4.5k68.3M56](/packages/knplabs-knp-snappy)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)

PHPackages © 2026

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