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

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

dreadnip/chrome-pdf-bundle
==========================

A wrapper around chrome-php/chrome to generate PDFs in Symfony projects

0.7.0(4mo ago)716.7k↓36.6%2MITHTMLPHP ^7.4 || ^8.0

Since Apr 11Pushed 4mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (16)Used By (0)

ChromePdfBundle
===============

[](#chromepdfbundle)

The ChromePdfBundle is a Symfony bundle that leverages the [chrome-php/chrome](https://github.com/chrome-php/chrome) project to render HTML and save the output as a PDF file.

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

[](#installation)

With [composer](https://getcomposer.org), require:

`composer require dreadnip/chrome-pdf-bundle`

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

[](#configuration)

The bundle relies on a working, up-to-date Chrome/Chromium instance to work. You must specify the binary in your .env file.

```
# .env or .env.local
CHROME_BINARY="/usr/bin/chromium"
```

Usage
-----

[](#usage)

The bundle registers two services:

- `chrome_pdf.pdf_generator` allows you to generate pdf files from HTML strings. You can autowire the `PdfGenerator` class in your application to get started quickly.
- `chrome_pdf.browser_factory` is the chrome-php/chrome BrowserFactory class offered as a service within your Symfony application. Use this if you want to fine-tune the PDF generation process. You can use the PdfGenerator class as a starting point and build your custom solution from that.

### Basic example: render a pdf document in a controller

[](#basic-example-render-a-pdf-document-in-a-controller)

```
use Dreadnip\ChromePdfBundle\Service\PdfGenerator;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;

class TestController extends AbstractController
{
    public function __invoke(PdfGenerator $pdfGenerator): Response
    {
        $html = $this->render('pdf.html.twig');

        $path = $pdfGenerator->generate($html, 'files/test.pdf');

        return new BinaryFileResponse($path);
    }
}
```

### Advanced example: render a pdf document in a controller with custom options

[](#advanced-example-render-a-pdf-document-in-a-controller-with-custom-options)

```
use Dreadnip\ChromePdfBundle\Service\PdfGenerator;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;

class TestController
{
    public function __invoke(
        Environment $twig,
        PdfGenerator $pdfGenerator
    ): Response {
        $html = $twig->render('pdf.html.twig');

        // Control everything by passing custom options
        $printOptions = [
            'printBackground' => true,
            'displayHeaderFooter' => true,
            'preferCSSPageSize' => true,
            'headerTemplate'=> "",
            'footerTemplate' => "",
            'scale' => 1.0,
        ];

        // Setting headless to false helps you debug issues
        $browserOptions = [
            'headless' => false,
        ];

        $path = $pdfGenerator->generate(
            html: $html,
            path: 'files/test.pdf',
            printOptions: $options,
            browserOptions: $browserOptions,
            timeout: 5000
        );

        return new BinaryFileResponse($path);
    }
}
```

[Print options](https://github.com/chrome-php/chrome#print-as-pdf) can be used to control the rendering of the PDF.

[Browser options](https://github.com/chrome-php/chrome#options) are available to control the headless Chrome instance that will be used to render the PDF.

A list of all available options can be found in the chrome-php/chrome repository.

### Base template

[](#base-template)

The bundle comes with a base template that can be extended to build PDFs with. This includes helpers for page lay-out and breaking. The template comes with two blocks `styles` for CSS and `content` for the actual PDF content.

```
{% extends '@ChromePdf/base.html.twig' %}

{% block content %}

        First page
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores enim maxime quasi? Ab accusantium at commodi corporis, distinctio earum facilis harum ipsum maxime, nisi nostrum obcaecati odit officia quod voluptatem?

        Second page
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores enim maxime quasi? Ab accusantium at commodi corporis, distinctio earum facilis harum ipsum maxime, nisi nostrum obcaecati odit officia quod voluptatem?

{% endblock %}
```

Credits
-------

[](#credits)

This bundle is nothing more than a simple wrapper around the awesome [chrome-php/chrome](https://github.com/chrome-php/headless-chromium-php) project.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance77

Regular maintenance activity

Popularity34

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.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 ~133 days

Recently: every ~347 days

Total

14

Last Release

126d ago

PHP version history (2 changes)0.1PHP ^7.4|^8.0

0.2.4PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/179d3921ac9d44fa878e41369464e08f45f322cde7fcc6d3764dc7268f25e0b7?d=identicon)[sanderdlm](/maintainers/sanderdlm)

---

Top Contributors

[![sanderdlm](https://avatars.githubusercontent.com/u/24303072?v=4)](https://github.com/sanderdlm "sanderdlm (4 commits)")[![kochen](https://avatars.githubusercontent.com/u/106042?v=4)](https://github.com/kochen "kochen (3 commits)")

---

Tags

chromechrome-phppdfsymfonysymfony-bundlesymfonypdfchromechromium

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[chrome-php/chrome

Instrument headless chrome/chromium instances from PHP

2.6k4.5M64](/packages/chrome-php-chrome)[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)[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[padam87/rasterize-bundle

HTML to PDF Symfony bundle. Works with Puppeteer, PhantomJS, and more.

1579.4k](/packages/padam87-rasterize-bundle)[nucleos/dompdf-bundle

This bundle provides a wrapper for using dompdf inside symfony.

54882.8k1](/packages/nucleos-dompdf-bundle)[bobv/latex-bundle

Latex and pdf generator for Symfony 2

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

PHPackages © 2026

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