PHPackages                             nucleos/dompdf-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. nucleos/dompdf-bundle

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

nucleos/dompdf-bundle
=====================

This bundle provides a wrapper for using dompdf inside symfony.

4.5.0(5mo ago)54882.8k—1.4%12[6 issues](https://github.com/nucleos/NucleosDompdfBundle/issues)[1 PRs](https://github.com/nucleos/NucleosDompdfBundle/pulls)1MITPHPPHP ^8.3CI passing

Since Jun 12Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/nucleos/NucleosDompdfBundle)[ Packagist](https://packagist.org/packages/nucleos/dompdf-bundle)[ Docs](https://nucleos.rocks)[ GitHub Sponsors](https://github.com/sponsors/core23)[ Fund](https://ko-fi.com/core23)[ RSS](/packages/nucleos-dompdf-bundle/feed)WikiDiscussions 4.6.x Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (34)Used By (1)

NucleosDompdfBundle
===================

[](#nucleosdompdfbundle)

[![Latest Stable Version](https://camo.githubusercontent.com/68f676b2a8f2f803e339f9053a597cb9e635ea044072fd5cfc3c8e2aced8e390/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f646f6d7064662d62756e646c652f762f737461626c65)](https://packagist.org/packages/nucleos/dompdf-bundle)[![Latest Unstable Version](https://camo.githubusercontent.com/b1f5158ffed02ab6a74c4d964d02601fb0a91ec96d783f932360e5afa3aa993d/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f646f6d7064662d62756e646c652f762f756e737461626c65)](https://packagist.org/packages/nucleos/dompdf-bundle)[![License](https://camo.githubusercontent.com/ca4d4f4873027bb15176ce897df4bb63772e3aa8bd357be767ae9c757fd248ee/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f646f6d7064662d62756e646c652f6c6963656e7365)](LICENSE.md)

[![Total Downloads](https://camo.githubusercontent.com/673a2502561ef41f64e334c9d1df0d874c79056626b9d44c153b89a4e139f7c7/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f646f6d7064662d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/nucleos/dompdf-bundle)[![Monthly Downloads](https://camo.githubusercontent.com/06de7f0565f8bc9bd5f9bd5e3722f1f877de9633bcea847c7aa3c93653c7715b/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f646f6d7064662d62756e646c652f642f6d6f6e74686c79)](https://packagist.org/packages/nucleos/dompdf-bundle)[![Daily Downloads](https://camo.githubusercontent.com/ee8c8ba9b0c7f5de1e869c152c76bce3295d3b04109011ae2a61ae450b435dcd/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f646f6d7064662d62756e646c652f642f6461696c79)](https://packagist.org/packages/nucleos/dompdf-bundle)

[![Continuous Integration](https://github.com/nucleos/NucleosDompdfBundle/actions/workflows/continuous-integration.yml/badge.svg?event=push)](https://github.com/nucleos/NucleosDompdfBundle/actions?query=workflow%3A%22Continuous+Integration%22+event%3Apush)[![Code Coverage](https://camo.githubusercontent.com/36f5f5ebb9de81a3228d378edd626502ff7aa717e0dc7ef1b191196979f2fd4e/68747470733a2f2f636f6465636f762e696f2f67682f6e75636c656f732f4e75636c656f73446f6d70646642756e646c652f67726170682f62616467652e737667)](https://codecov.io/gh/nucleos/NucleosDompdfBundle)

This bundle provides a wrapper for using [dompdf](https://github.com/dompdf/dompdf) inside Symfony.

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

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
composer require nucleos/dompdf-bundle

```

### Enable the Bundle

[](#enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    Nucleos\DompdfBundle\NucleosDompdfBundle::class => ['all' => true],
];
```

Configure the Bundle
--------------------

[](#configure-the-bundle)

```
# config/packages/nucleos_dompdf.yaml

nucleos_dompdf:
    defaults:
        defaultFont: 'helvetica'
        # See https://github.com/dompdf/dompdf/wiki/Usage#options for available options
```

Usage
-----

[](#usage)

Whenever you need to turn a html page into a PDF use dependency injection for your service:

```
use Nucleos\DompdfBundle\Factory\DompdfFactoryInterface;
use Nucleos\DompdfBundle\Wrapper\DompdfWrapperInterface;

final class MyService
{
    public function __construct(DompdfFactoryInterface $factory)
    {
        $this->factory = $factory;
    }

    public function render()
    {
        // ...
        /** @var Dompdf\Dompdf $dompdf */
        $dompdf = $this->factory->create();
        // Or pass an array of options:
        $dompdf = $this->factory->create(['chroot' => '/home']);
        // ...
    }
}

final class MyOtherService
{
    public function __construct(DompdfWrapperInterface $wrapper)
    {
        $this->wrapper = $wrapper;
    }

    public function stream()
    {
        // ...
        $html = 'Sample TitleLorem Ipsum';

        /** @var Symfony\Component\HttpFoundation\StreamedResponse $response */
        $response = $this->wrapper->getStreamResponse($html, "document.pdf");
        $response->send();
        // ...
    }

    public function binaryContent()
    {
        // ...
        return $this->wrapper->getPdf($html);
        // ...
    }
}
```

### Render pdf using Twig

[](#render-pdf-using-twig)

If you use Twig to create the content, make sure to use `renderView()` instead of `render()`. Otherwise you might get the following HTTP header printed inside your PDF:

> HTTP/1.0 200 OK Cache-Control: no-cache

```
$html = $this->renderView('my_pdf.html.twig', array(
    // ...
));
$this->wrapper->getStreamResponse($html, 'document.pdf');
```

### Using asset() to link assets

[](#using-asset-to-link-assets)

First, make sure your `chroot` is correctly set and `isRemoteEnabled` is true.

```
# config/packages/nucleos_dompdf.yaml

nucleos_dompdf:
    defaults:
        chroot: '%kernel.project_dir%/public/assets'
        isRemoteEnabled: true
```

Second, use `{{ absolute_url( asset() ) }}`

```

```

### Events

[](#events)

The dompdf wrapper dispatches events to conveniently get the inner dompdf instance when creating the PDF.

- `dompdf.output` is dispatched in `getPdf()`
- `dompdf.stream` is dispatched in `streamHtml()`

See [Symfony Events and Event Listeners](https://symfony.com/doc/current/event_dispatcher.html) for more info.

License
-------

[](#license)

This bundle is under the [MIT license](LICENSE.md).

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance80

Actively maintained with recent releases

Popularity52

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~128 days

Recently: every ~14 days

Total

28

Last Release

164d ago

Major Versions

1.0.1 → 2.0.02017-09-14

2.6.0 → 3.0.02020-06-26

3.2.x-dev → 4.0.02022-07-09

PHP version history (7 changes)1.0.0PHP ^5.6 || ^7.0

2.0.0PHP ^7.1

2.5.0PHP ^7.2

3.1.0PHP ^7.3 || ^8.0

3.2.0PHP ^8.0

4.1.0PHP ^8.1

4.4.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/46179d0f1a863a1a71c634a413d857f8428ad9a8273cd065ba4f0e864730dde9?d=identicon)[core23](/maintainers/core23)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (379 commits)")[![core23](https://avatars.githubusercontent.com/u/3440437?v=4)](https://github.com/core23 "core23 (374 commits)")[![nucleos-bot](https://avatars.githubusercontent.com/u/60489587?v=4)](https://github.com/nucleos-bot "nucleos-bot (231 commits)")[![kodiakhq[bot]](https://avatars.githubusercontent.com/in/29196?v=4)](https://github.com/kodiakhq[bot] "kodiakhq[bot] (35 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (13 commits)")[![reyostallenberg](https://avatars.githubusercontent.com/u/3579090?v=4)](https://github.com/reyostallenberg "reyostallenberg (6 commits)")[![ThomasLandauer](https://avatars.githubusercontent.com/u/1054469?v=4)](https://github.com/ThomasLandauer "ThomasLandauer (5 commits)")[![fd6130](https://avatars.githubusercontent.com/u/11419744?v=4)](https://github.com/fd6130 "fd6130 (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (2 commits)")[![kl3sk](https://avatars.githubusercontent.com/u/2953145?v=4)](https://github.com/kl3sk "kl3sk (1 commits)")[![julienlegrand07](https://avatars.githubusercontent.com/u/3482402?v=4)](https://github.com/julienlegrand07 "julienlegrand07 (1 commits)")[![kevin-lot](https://avatars.githubusercontent.com/u/5575659?v=4)](https://github.com/kevin-lot "kevin-lot (1 commits)")[![Kitee666](https://avatars.githubusercontent.com/u/18664027?v=4)](https://github.com/Kitee666 "Kitee666 (1 commits)")[![84m](https://avatars.githubusercontent.com/u/11029558?v=4)](https://github.com/84m "84m (1 commits)")[![tgeber](https://avatars.githubusercontent.com/u/4496896?v=4)](https://github.com/tgeber "tgeber (1 commits)")

---

Tags

bundledompdfhacktoberfestpdfphpsymfonysymfony-bundlewrappersymfonybundlepdfwrapperdompdf

### Embed Badge

![Health badge](/badges/nucleos-dompdf-bundle/health.svg)

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

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sensiolabs/gotenberg-bundle

A Symfony bundle that provides seamless integration with Gotenberg for generating PDFs and screenshots from various sources (HTML, Markdown, Office documents, URLs) with a clean, builder-based API.

210210.4k2](/packages/sensiolabs-gotenberg-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)

PHPackages © 2026

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