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

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

daif/chrome-pdf-bundle
======================

A Symfony bundle for generating PDFs and screenshots using a local Chrome/Chromium binary via Chrome DevTools Protocol, with a clean, builder-based API.

v0.9.0-alpha(3mo ago)12MITPHPPHP &gt;=8.1CI passing

Since Feb 10Pushed 3mo agoCompare

[ Source](https://github.com/daifma/chrome-pdf-bundle)[ Packagist](https://packagist.org/packages/daif/chrome-pdf-bundle)[ RSS](/packages/daif-chrome-pdf-bundle/feed)WikiDiscussions main Synced 1w ago

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

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

[](#chromepdfbundle)

### *WYSIWYPDF* -- What You See Is What You PDF

[](#wysiwypdf----what-you-see-is-what-you-pdf)

> The dockerless PDF generator for Symfony. Just Chrome. No containers, no wrapping, no kidding.

 ```
composer require daif/chrome-pdf-bundle
```

Why this bundle?
----------------

[](#why-this-bundle)

I wanted to use [sensiolabs/gotenberg-bundle](https://github.com/sensiolabs/GotenbergBundle) -- it's a great and complete Symfony bundle for PDF generation. But it relies on [Gotenberg](https://gotenberg.dev/), which requires a running **Docker container**.

In my case, working in **on-premise environments** (banking, insurance, regulated industries), Docker is simply not available on production servers. Security policies and infrastructure constraints prevent running containers.

Yet these same machines almost always have a **browser installed**, or can easily add one. Google Chrome and Chromium are well-maintained, widely trusted, and available on virtually every Linux distribution through standard package managers.

So I built **ChromePdfBundle**: the same clean builder-based API, but driving Chrome/Chromium **directly** via the Chrome DevTools Protocol -- no Docker, no external service, no extra infrastructure.

Docker-based solutionsChromePdfBundleRequire Docker + a running containerRequires only a Chrome/Chromium binaryHTTP calls to an external serviceDirect communication via CDPExtra infrastructure to maintainUses a browser already on the systemNot usable in Docker-free environmentsWorks everywhere Chrome runsHow to install
--------------

[](#how-to-install)

### Requirements

[](#requirements)

- PHP 8.1+
- Symfony 6.4 / 7.x / 8.x
- Google Chrome or Chromium installed on the system (see [Chrome installation guide](./docs/chrome-installation.md))

```
composer require daif/chrome-pdf-bundle
```

This installs the bundle along with [chrome-php/chrome](https://github.com/chrome-php/chrome), the PHP library used to communicate with Chrome via the DevTools Protocol.

### Enable the bundle

[](#enable-the-bundle)

If not using Symfony Flex, manually register the bundle:

```
// config/bundles.php

return [
    // ...
    Daif\ChromePdfBundle\DaifChromePdfBundle::class => ['all' => true],
];
```

### Configuration

[](#configuration)

Create a minimal configuration:

```
# config/packages/daif_chrome_pdf.yaml

daif_chrome_pdf:
    assets_directory: '%kernel.project_dir%/assets'
```

The bundle will automatically detect Chrome/Chromium on your system. You can also specify the binary path explicitly:

```
daif_chrome_pdf:
    chrome_binary: '/usr/bin/google-chrome'
```

Basic Usage
-----------

[](#basic-usage)

### PDF from Twig template

[](#pdf-from-twig-template)

```
namespace App\Controller;

use Daif\ChromePdfBundle\ChromePdfInterface;
use Symfony\Component\HttpFoundation\Response;

class InvoiceController
{
    public function generateInvoice(ChromePdfInterface $chromePdf): Response
    {
        return $chromePdf->html()
            ->content('invoice.html.twig', [
                'invoice' => $invoice,
            ])
            ->generate()
            ->stream()
        ;
    }
}
```

### PDF from URL

[](#pdf-from-url)

```
use Daif\ChromePdfBundle\ChromePdfInterface;

class ReportController
{
    public function generateReport(ChromePdfInterface $chromePdf): Response
    {
        return $chromePdf->url()
            ->url('https://example.com/report')
            ->generate()
            ->stream()
        ;
    }
}
```

### PDF from Markdown

[](#pdf-from-markdown)

```
use Daif\ChromePdfBundle\ChromePdfInterface;

class DocController
{
    public function generateDoc(ChromePdfInterface $chromePdf): Response
    {
        return $chromePdf->markdown()
            ->wrapper('wrapper.html.twig')
            ->files('content.md')
            ->generate()
            ->stream()
        ;
    }
}
```

### Screenshot

[](#screenshot)

```
use Daif\ChromePdfBundle\ChromeScreenshotInterface;

class ScreenshotController
{
    public function capture(ChromeScreenshotInterface $chromeScreenshot): Response
    {
        return $chromeScreenshot->html()
            ->content('page.html.twig')
            ->generate()
            ->stream()
        ;
    }
}
```

### Twig assets

[](#twig-assets)

If a template needs to link to a static asset (image, CSS, font), use the `{{ chrome_pdf_asset() }}` Twig function:

```

    My PDF

```

Advanced Usage
--------------

[](#advanced-usage)

1. [Chrome installation guide](./docs/chrome-installation.md)
2. [Configuration](./docs/configuration.md)
3. [Processing (saving, streaming, S3...)](./docs/processing.md)
4. [Working with assets](./docs/assets.md)
5. [Working with fonts](./docs/fonts.md)

### PDF

[](#pdf)

1. [HTML Builder](./docs/pdf/HtmlPdfBuilder.md)
2. [URL Builder](./docs/pdf/UrlPdfBuilder.md)
3. [Markdown Builder](./docs/pdf/MarkdownPdfBuilder.md)
4. [Header / Footer](./docs/pdf/header-footer.md)

### Screenshot

[](#screenshot-1)

1. [HTML Builder](./docs/screenshot/HtmlScreenshotBuilder.md)
2. [URL Builder](./docs/screenshot/UrlScreenshotBuilder.md)
3. [Markdown Builder](./docs/screenshot/MarkdownScreenshotBuilder.md)

Licence
-------

[](#licence)

MIT License (MIT): see the [License File](LICENSE) for more details.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance78

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

119d ago

### Community

Maintainers

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

---

Top Contributors

[![daifma](https://avatars.githubusercontent.com/u/4672529?v=4)](https://github.com/daifma "daifma (1 commits)")

---

Tags

symfonybundlepdfchromescreenshotchromium

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sulu/sulu

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

1.3k1.4M195](/packages/sulu-sulu)[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.

229308.8k2](/packages/sensiolabs-gotenberg-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M370](/packages/easycorp-easyadmin-bundle)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M395](/packages/drupal-core-recommended)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M506](/packages/shopware-core)[contao/core-bundle

Contao Open Source CMS

1231.6M2.6k](/packages/contao-core-bundle)

PHPackages © 2026

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