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

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

dgarden/gotenberg-bundle
========================

Gotenberg PDF generation bundle

v0.2.0(11mo ago)03MITPHP

Since Apr 28Pushed 11mo agoCompare

[ Source](https://github.com/dgardenfr/gotenberg-bundle)[ Packagist](https://packagist.org/packages/dgarden/gotenberg-bundle)[ RSS](/packages/dgarden-gotenberg-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (3)Used By (0)

Digital Garden Gotenberg Bundle.
================================

[](#digital-garden-gotenberg-bundle)

Installation guide
------------------

[](#installation-guide)

To install this bundle, just do :

```
composer require dgarden/gotenberg-bundle
```

If you're in a symfony project with `config/routes` and `config/packages`, configuration has to be created, if not you can copy/paste these configurations :

```
# config/packages/dgarden_gotenberg.yaml
dgarden:
  gotenberg:
    output_path: '%kernel.project_dir%/var/pdf'
```

```
# config/routes/dgarden_gotenberg.yaml
dgarden_gotenberg:
  resource: '@DigitalGardenGotenbergBundle/config/routes.php'
```

With flex enabled, you should also have [Sensiolabs Gotenberg bundle](https://github.com/sensiolabs/GotenbergBundle)configuration file created :

```
# config/packages/gotenberg.yaml

framework:
    http_client:
        scoped_clients:
            gotenberg.client:
                base_uri: '%env(GOTENBERG_DSN)%'

sensiolabs_gotenberg:
    http_client: 'gotenberg.client'
#    default_options:
#        pdf:
#            html:
#                metadata:
#                    Keywords: 'Symfony'
```

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

[](#configuration)

Digital Garden Gotenberg Bundle's configuration :

```
dgarden:
  gotenberg:
    output_path: 'string'  // Specify the default output for generated pdf files.
```

Check also the [Sensiolabs Gotenberg bundle](https://github.com/sensiolabs/GotenbergBundle) documentation to know how to configure the connexion to the Gotenberg API, but mainly you'll just have to set the environment variable `GOTENBERG_DSN`.

For example (set has default env variable in `config/packages/gotenberg.yaml`):

```
# config/packages/gotenberg.yaml
parameters:
  env(GOTENBERG_DSN): 'https://gotenberg:gotenberg@gotenberg.gulfstream-group.fr'

# ...
```

Service PdfFileGenerator
------------------------

[](#service-pdffilegenerator)

This bundle add to the container a new service `dgarden.gotenberg.generator` or ̀`DigitalGarden\GotenbergBundle\Generator\PdfFileGeneratorInterface` with the following helpers :

- `html(string $html, string $output, PdfFileGeneratorOptions|array $options = PdfFileGeneratorOptions::DEFAULT): SplFileInfo;` : Generate a PDF file from HTML.

    Example:

    ```
