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

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

spraed/pdf-generator-bundle
===========================

This bundle creates (multiple) PDFs in Symfony from Twig/HTML templates.

v1.13.2(4mo ago)52525.2k↓20.2%15[2 issues](https://github.com/stedekay/SpraedPDFGeneratorBundle/issues)MITPHPPHP ^8.0CI failing

Since Sep 23Pushed 4mo ago5 watchersCompare

[ Source](https://github.com/stedekay/SpraedPDFGeneratorBundle)[ Packagist](https://packagist.org/packages/spraed/pdf-generator-bundle)[ Docs](https://github.com/stedekay/SpraedPDFGeneratorBundle)[ RSS](/packages/spraed-pdf-generator-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (3)Versions (24)Used By (0)

SpraedPDFGeneratorBundle
========================

[](#spraedpdfgeneratorbundle)

SpraedPDFGeneratorBundle generates HTML documents to PDF. The bundle gives you the chance to add a page header and footer very easily (which can be disabled/switched on the first page).

It works with a little jar library based on the \[Flying Saucer project\]\[flyingsaucer\]. So you need to run Java on your server (Java 6 or later).

[![Total Downloads](https://camo.githubusercontent.com/358dbbdf83a115ba7f6d2e096d6016c2202d6f365649b5f46e00788c30f49e4c/68747470733a2f2f706f7365722e707567782e6f72672f7370726165642f7064662d67656e657261746f722d62756e646c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/spraed/pdf-generator-bundle) [![Latest Stable Version](https://camo.githubusercontent.com/6faa19a2cf4aa4669dd04adcfd4f446267f77ab6fbef7a194e421015b4ba1ae4/68747470733a2f2f706f7365722e707567782e6f72672f7370726165642f7064662d67656e657261746f722d62756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/spraed/pdf-generator-bundle)

Installation using Composer
---------------------------

[](#installation-using-composer)

```
composer require spraed/pdf-generator-bundle

```

Usage
-----

[](#usage)

There is a service registered in the services.yml to generate pdf files. Just call the PDF generator from the service class and call the generatePDF() method with the XHTML and the url of the PDF:

```
$html = $this->renderView('AcmeDemoBundle:Default:index.html.twig');
$pdfGenerator = $this->get('spraed.pdf.generator');

```

Also you are able to set an encoding option (you can leave the second parameter, it defaults to UTF-8):

```
$pdfGenerator->generatePDF($html, 'UTF-8');

```

Anything else will be handled by the Response object in the controller, i.e.:

```
    $html = $this->renderView('ACMEYourBundle:Print:print.html.twig');
    $pdfGenerator = $this->get('spraed.pdf.generator');

    return new Response($pdfGenerator->generatePDF($html),
                    200,
                    array(
                        'Content-Type' => 'application/pdf',
                        'Content-Disposition' => 'inline; filename="out.pdf"'
                    )
    );

```

If you wish the pdf to be offered as a download, simply change 'inline' in 'Content-Disposition' to 'attachment'.

Make sure that all assets in your HTML are linked with absolute paths, because the HTML is copied into a tmp folder on the server. If you want to add an image to your twig it should look something like this:

```
    {{ app.request.scheme ~'://' ~ app.request.httpHost ~ asset('images/foo.jpg') }}

```

You are also capable of printing multiple pdfs in one stack. Saying you generate multiple documents from multiple html files and you want to output those in on huge pdf file, there is the 'generatePDFs' method which takes an array of rendered html Views and sticks those together:

```
    $twigs[0] = 'SpraedSomethingBundle:Print:print_pdf_one.html.twig'
    $twigs[1] = 'SpraedSomethingBundle:Print:print_pdf_two.html.twig'

    $htmlCollection = array();
    foreach($twigs as $twig){
            $htmlCollection[] = $this->renderView($twig);
    }

    return new Response($pdfGenerator->generatePDFs($htmlCollection, 'UTF-8'),
        200,
        array(
            'Content-Type' => 'application/pdf',
            'Content-Disposition' => 'inline; filename="out.pdf"'
        )
    );

```

To define proper print css you might want to read into the w3.org's hints on that: \[w3.org\] \[w3.org\]: \[flyingsaucer\]: \[spraed\]:

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

[](#configuration)

Example configuration options:

```
    spraed_pdf_generator:
        command:
            env:
                FOO: BAR
        java:
            full_path: /path/to/java

```

The command environment will add environment variables when running the Java application.

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance75

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 78.8% 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 ~206 days

Recently: every ~180 days

Total

23

Last Release

128d ago

PHP version history (6 changes)v1.0PHP &gt;=5.3.2

v1.4PHP &gt;=5.3.2|^7.0

v1.5PHP ^5.6|^7.0

v1.7.0PHP ^7.2

v1.8.0PHP ^7.2|^8.0

v1.11.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/228ffe574dc41db64ed5963233c464de7c0ce9318c8e936bd48804b2848edeb2?d=identicon)[stedekay](/maintainers/stedekay)

---

Top Contributors

[![stedekay](https://avatars.githubusercontent.com/u/1071560?v=4)](https://github.com/stedekay "stedekay (78 commits)")[![kernel64](https://avatars.githubusercontent.com/u/1070435?v=4)](https://github.com/kernel64 "kernel64 (8 commits)")[![rodnaph](https://avatars.githubusercontent.com/u/447579?v=4)](https://github.com/rodnaph "rodnaph (5 commits)")[![Mexicanoon](https://avatars.githubusercontent.com/u/60662240?v=4)](https://github.com/Mexicanoon "Mexicanoon (2 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![stefanheppenheimer](https://avatars.githubusercontent.com/u/833300?v=4)](https://github.com/stefanheppenheimer "stefanheppenheimer (1 commits)")[![Gonzalo1987](https://avatars.githubusercontent.com/u/7010439?v=4)](https://github.com/Gonzalo1987 "Gonzalo1987 (1 commits)")[![inmarelibero](https://avatars.githubusercontent.com/u/254808?v=4)](https://github.com/inmarelibero "inmarelibero (1 commits)")[![jameskitt616](https://avatars.githubusercontent.com/u/52933658?v=4)](https://github.com/jameskitt616 "jameskitt616 (1 commits)")

---

Tags

bundlepdfgeneratorspraed

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[nucleos/dompdf-bundle

This bundle provides a wrapper for using dompdf inside symfony.

551.0M1](/packages/nucleos-dompdf-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[bobv/latex-bundle

Latex and pdf generator for Symfony 2

2333.8k](/packages/bobv-latex-bundle)

PHPackages © 2026

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