PHPackages                             leo-moshko/gotenberg-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. leo-moshko/gotenberg-bundle

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

leo-moshko/gotenberg-bundle
===========================

Gotenberg support for Symfony

v1.1.0(4mo ago)0113↓50%MITPHPPHP &gt;=8.1

Since Dec 14Pushed 4mo agoCompare

[ Source](https://github.com/LeoMoshko/GotenbergBundle)[ Packagist](https://packagist.org/packages/leo-moshko/gotenberg-bundle)[ RSS](/packages/leo-moshko-gotenberg-bundle/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (1)Dependencies (32)Versions (2)Used By (0)

  ![SensioLabs Gotenberg Bundle for Symfony](./docs/images/gotenbergbundle.dark.png) ```
composer require sensiolabs/gotenberg-bundle
```

[![Latest Version](https://camo.githubusercontent.com/e567469f870e51a8b39d035c3212cc55c8579bf138871ad37eb4e51055158fb9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73656e73696f6c6162732f476f74656e6265726742756e646c652e7376673f7374796c653d666c61742d737175617265)](https://github.com/sensiolabs/GotenbergBundle/releases)[![Total Downloads](https://camo.githubusercontent.com/3a1d29a7d21a2504dffc01b349da809039c266d9b57d670eb88fc9a3e7a850ec/68747470733a2f2f706f7365722e707567782e6f72672f73656e73696f6c6162732f676f74656e626572672d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/sensiolabs/gotenberg-bundle)[![Monthly Downloads](https://camo.githubusercontent.com/9745c92e89e75db6bac86d3abf64b5dfa9d6606a50a7184b174a1ae3c9a150bf/68747470733a2f2f706f7365722e707567782e6f72672f73656e73696f6c6162732f676f74656e626572672d62756e646c652f642f6d6f6e74686c79)](https://packagist.org/packages/sensiolabs/gotenberg-bundle)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENCE)[![Static analysis](https://github.com/sensiolabs/GotenbergBundle/actions/workflows/static.yml/badge.svg?branch=1.x)](https://github.com/sensiolabs/GotenbergBundle/actions/workflows/static.yml?query=branch%3A1.x)[![Tests](https://github.com/sensiolabs/GotenbergBundle/actions/workflows/unit-tests.yml/badge.svg?branch=1.x)](https://github.com/sensiolabs/GotenbergBundle/actions/workflows/unit-tests.yml?query=branch%3A1.x)

Generate PDFs and screenshots with Symfony!
-------------------------------------------

[](#generate-pdfs-and-screenshots-with-symfony)

This bundle allows you to generate, stream and save PDF locally from URL, HTML, Markdown or any Office file. Different options are available depending on the source.

It also helps you to generate, stream and save images locally from URL, HTML and Markdown by taking a screenshot.

Note

This bundle interacts with the amazing [Gotenberg](https://gotenberg.dev/docs/getting-started/installation) API which is used under the hood.

📦 [How to install](#how-to-install)

⭐ [Basic Usage](#basic-usage)

🌟 [Advanced Usage](#advanced-usage)

🔎 [Profiler](#profiler)

✅ [Testing](#testing)

🙋 [FAQ](#faq)

❤️ [Credits](#credits)

📃 [Licence](#licence)

How to install
--------------

[](#how-to-install)

Note

You first need to install and configure [Gotenberg 8.x](https://gotenberg.dev/docs/getting-started/installation) by yourself.

Install the bundle using composer:

```
composer require sensiolabs/gotenberg-bundle
```

### With Symfony Flex

[](#with-symfony-flex)

If you accept the Symfony Flex recipe during installation:

- The bundle will be automatically registered.
- A configuration skeleton file will be created.
- Docker Compose will be updated with a new gotenberg service.
- The `.env` file will be updated with a `GOTENBERG_DSN` value pointing to `gotenberg:3000`. You can update this value if your Gotenberg instance is hosted elsewhere.

### Without Symfony Flex

[](#without-symfony-flex)

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

```
// config/bundles.php

return [
    // ...
    Sensiolabs\GotenbergBundle\SensiolabsGotenbergBundle::class => ['all' => true],
];
```

Create a configuration and adapt to your needs:

```
# ./config/packages/sensiolabs_gotenberg.yaml

framework:
    http_client:
        scoped_clients:
            gotenberg.client:
                base_uri: 'http://gotenberg:3000'

sensiolabs_gotenberg:
    http_client: 'gotenberg.client'
```

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

[](#basic-usage)

### PDF

[](#pdf)

You can generate a PDF locally from URL, HTML, Markdown or any Office files.

#### URL

[](#url)

After injecting `GotenbergPdfInterface` you simply need to call the method `url`, which will return a `UrlPdfBuilder` instance.

`UrlPdfBuilder` lets you pass the URL of the page you want to convert into PDF to the method `url`.

```
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
    public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
    {
        return $gotenberg->url()
            ->url('https://sensiolabs.com/fr/')
            ->generate()
            ->stream() // will return directly a stream response
        ;
    }
}
```

Tip

For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#url-into-pdf-route).

#### Twig

[](#twig)

Warning

Every Twig template you pass to Gotenberg must have the following structure. Even Header or Footer parts.

```
>

        My PDF

```

```
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
    public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
    {
        return $gotenberg->html()
            ->content('twig_simple_pdf.html.twig', [
                'my_var' => 'value'
            ])
            ->generate()
            ->stream() // will return directly a stream response
        ;
    }
}
```

If a template needs to link to a static asset (e.g. an image), this bundle provides a `{{ gotenberg_asset() }}` Twig function to generate the correct path AND add it to the builder automatically.

This function work as [asset() Twig function](https://symfony.com/doc/current/templates.html#linking-to-css-javascript-and-image-assets) and fetch your assets in the `assets` folder of your application. If your files are in another folder, you can override the default value of `assets_directory`in your configuration file `config/sensiolabs_gotenberg.yml`. The path provided can be relative as well as absolute.

```

    PDF body

        Hello world!

```

Tip

For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#html-file-into-pdf-route).

### Screenshot

[](#screenshot)

You can generate a screenshot locally from URL, HTML and Markdown.

#### URL

[](#url-1)

After injecting `GotenbergScreenshotInterface` you simply need to call the method `url`, which will return a `UrlScreenshotBuilder` instance.

`UrlScreenshotBuilder` lets you pass the URL of the page you want to convert into screenshot to the method `url`.

```
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergScreenshotInterface;

class YourController
{
    public function yourControllerMethod(GotenbergScreenshotInterface $gotenberg): Response
    {
        return $gotenberg->url()
             ->url('https://sensiolabs.com/fr/')
             ->generate()
             ->stream()
        ;
    }
}
```

#### Twig

[](#twig-1)

After injecting `GotenbergScreenshotInterface` you simply need to call the method `html`, which will return a `HtmlScreenshotBuilder` instance.

`HtmlScreenshotBuilder` lets you pass the content of the page you want to convert into screenshot to the method `content`.

```
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergScreenshotInterface;

class YourController
{
    public function yourControllerMethod(GotenbergScreenshotInterface $gotenberg): Response
    {
        return $gotenberg->html()
            ->content('twig_simple_pdf.html.twig', [
                 'my_var' => 'value'
            ])
            ->generate()
            ->stream()
        ;
    }
}
```

Tip

For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#screenshots-route).

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

[](#advanced-usage)

1. [Configuration](./docs/configuration.md)
2. [Processing (saving for example)](./docs/processing.md)
3. [Working with assets](./docs/assets.md)
4. [Async &amp; Webhooks](./docs/webhook.md)
5. [Working with fonts](./docs/fonts.md)

### PDF

[](#pdf-1)

1. [Add header / footer](./docs/pdf/header-footer.md)
2. [HTML Builder](./docs/pdf/HtmlPdfBuilder.md)
3. [Markdown Builder](./docs/pdf/MarkdownPdfBuilder.md)
4. [Url Builder](./docs/pdf/UrlPdfBuilder.md)
5. [Office Builder](./docs/pdf/LibreOfficePdfBuilder.md) (available extensions for conversion below)

    📝 `doc`, `docx`, `docm`, `dot`, `dotx`, `dotm`, `odt`, `ott`, `sdw`, `stw`, `sxw`, `sxg`, `fodt`, `rtf`, `txt`,

    `abw`, `zabw`, `cwk`, `psw`, `lwp`, `mcw`, `wpd`, `wps`, `pages`, `hwp`, `uof`, `uot`

    📊 `xls`, `xlsx`, `xlsm`, `xlsb`, `xlt`, `xltx`, `xltm`, `xlw`, `ods`, `ots`, `sdc`, `stc`, `sxc`, `uos`, `csv`,

    `dif`, `slk`, `123`, `wk1`, `wks`, `wb2`

    📽️ `ppt`, `pptx`, `pptm`, `pot`, `potx`, `potm`, `pps`, `odp`, `otp`, `sdd`, `sdp`, `sxi`, `sti`, `uop`, `key`

    🖼️ `svg`, `cdr`, `odg`, `otg`, `sda`, `sxd`, `std`, `svm`, `fodg`, `eps`, `emf`, `wmf`, `dxf`, `cgm`, `cmx`, `met`,

    `mml`, `vdx`, `vsd`, `vsdx`, `vsdm`, `vor`, `bmp`, `gif`, `jpeg`, `jpg`, `png`, `tif`, `tiff`, `pbm`, `pgm`,

    `ppm`, `ras`, `pcx`, `pcd`, `pct`, `psd`, `tga`, `xbm`, `xpm`, `wpg`

    📚 `epub`, `pdf`, `odd`, `odm`, `oth`, `html`, `htm`, `xhtml`, `xml`, `pub`, `pwp`, `bib`, `ltx`

    🗃️ `dbf`, `pdb`, `wb2`, `mw`

    🧩 `swf`, `smf`

    🏗️ `dxf`, `vdx`, `vsd`, `vsdx`, `vsdm`

    🧪 `sxm`, `mml`, `ltx`, `mw`
6. [Merge Builder](./docs/pdf/MergePdfBuilder.md)
7. [Convert Builder](./docs/pdf/ConvertPdfBuilder.md)
8. [Split Builder](./docs/pdf/SplitPdfBuilder.md)
9. [Flatten Builder](./docs/pdf/FlattenPdfBuilder.md)

### Screenshot

[](#screenshot-1)

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

Profiler
--------

[](#profiler)

Comes with a built-in profiler panel to help you during your development.

  ![SensioLabs Gotenberg Bundle profiler](./docs/images/profiler.dark.png)Testing
-------

[](#testing)

This bundle provides classes to assist with testing when using [PHPUnit](https://phpunit.de/).

1. [Creating mock results](./docs/testing.md#creating-mock-results)
2. [Builder Testing Support](./docs/testing.md#builder-testing-support)

FAQ
---

[](#faq)

 My PDF / Screenshot is blank but I have no errors! It may be because Gotenberg is trying to access an invalid URL (when using the `-&gt;url()` or `-&gt;route()` modes). For example if Gotenberg tries to access a page on `https://localhost:8001` but the SSL is a local provided one. Then Chromium won't be able to authorize access to the website. To fix this you can update your Gotenberg Docker service as followed: ```
--- a/compose.yaml
+++ b/compose.yaml
@@ -1,6 +1,9 @@
services:
     gotenberg:
         image: 'gotenberg/gotenberg:8'
+         command:
+             - 'gotenberg'
+             - '--chromium-ignore-certificate-errors'
```

It can also be because from Gotenberg PoV the URL of your Symfony app is not reachable. Let's say you are using [symfony CLI](https://symfony.com/download) to run your project locally with Gotenberg running in Docker. You need to configure the `request_context` like so:

```
--- a/config/packages/gotenberg.yaml
+++ b/config/packages/gotenberg.yaml
@@ -6,5 +6,5 @@ framework:

sensiolabs_gotenberg:
    http_client: 'gotenberg.client'
+    request_context:
+        base_uri: 'http://host.docker.internal:8000' # 8000 is the port Symfony CLI is running my app on.
```

Upgrade
-------

[](#upgrade)

[UPGRADE FROM 0.4.0 to 1.0.0](./UPGRADE-1.0.md)

Credits
-------

[](#credits)

This bundle was inspired by [Gotenberg PHP](https://github.com/gotenberg/gotenberg-php).

- [Steven RENAUX](https://github.com/StevenRenaux)
- [Adrien ROCHES](https://github.com/Neirda24)
- [Hubert LENOIR](https://github.com/Jean-Beru)
- [All Contributors](../../contributors)

Licence
-------

[](#licence)

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

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance78

Regular maintenance activity

Popularity13

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

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

Total

2

Last Release

145d ago

### Community

Maintainers

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

---

Top Contributors

[![StevenRenaux](https://avatars.githubusercontent.com/u/59167761?v=4)](https://github.com/StevenRenaux "StevenRenaux (48 commits)")[![Neirda24](https://avatars.githubusercontent.com/u/7036794?v=4)](https://github.com/Neirda24 "Neirda24 (35 commits)")[![Jean-Beru](https://avatars.githubusercontent.com/u/6114779?v=4)](https://github.com/Jean-Beru "Jean-Beru (20 commits)")[![smnandre](https://avatars.githubusercontent.com/u/1359581?v=4)](https://github.com/smnandre "smnandre (8 commits)")[![maelanleborgne](https://avatars.githubusercontent.com/u/11990607?v=4)](https://github.com/maelanleborgne "maelanleborgne (4 commits)")[![awurth](https://avatars.githubusercontent.com/u/10026857?v=4)](https://github.com/awurth "awurth (3 commits)")[![94noni](https://avatars.githubusercontent.com/u/1358361?v=4)](https://github.com/94noni "94noni (2 commits)")[![LeoMoshko](https://avatars.githubusercontent.com/u/9072581?v=4)](https://github.com/LeoMoshko "LeoMoshko (2 commits)")[![JorickPepin](https://avatars.githubusercontent.com/u/48644518?v=4)](https://github.com/JorickPepin "JorickPepin (1 commits)")[![mleczakm](https://avatars.githubusercontent.com/u/3474636?v=4)](https://github.com/mleczakm "mleczakm (1 commits)")[![jmsche](https://avatars.githubusercontent.com/u/3929498?v=4)](https://github.com/jmsche "jmsche (1 commits)")[![GromNaN](https://avatars.githubusercontent.com/u/400034?v=4)](https://github.com/GromNaN "GromNaN (1 commits)")[![ConstantBqt](https://avatars.githubusercontent.com/u/22151118?v=4)](https://github.com/ConstantBqt "ConstantBqt (1 commits)")[![tautvilas](https://avatars.githubusercontent.com/u/1044090?v=4)](https://github.com/tautvilas "tautvilas (1 commits)")

---

Tags

symfonybundlepdfofficescreenshotGotenberg

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/leo-moshko-gotenberg-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/leo-moshko-gotenberg-bundle/health.svg)](https://phpackages.com/packages/leo-moshko-gotenberg-bundle)
```

###  Alternatives

[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)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M385](/packages/shopware-core)

PHPackages © 2026

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