PHPackages                             heimrichhannot/contao-pdf-creator-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. heimrichhannot/contao-pdf-creator-bundle

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

heimrichhannot/contao-pdf-creator-bundle
========================================

A generic pdf creation bundle

0.4.10(10mo ago)0842↓40.5%LGPL-3.0-or-laterPHPPHP ^8.1

Since Mar 1Pushed 10mo ago5 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-pdf-creator-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-pdf-creator-bundle)[ RSS](/packages/heimrichhannot-contao-pdf-creator-bundle/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (15)Versions (19)Used By (0)

Contao PDF Creator Bundle
=========================

[](#contao-pdf-creator-bundle)

This bundle adds a generic way to configure the creation of pdf files, reuse these configurations and create pdfs on base of them. It's based on [PDF Creator library](https://github.com/heimrichhannot/pdf-creator).

Features
--------

[](#features)

- add PDF configurations from backend module or yaml
- can be easily used in your bundle
- bundled support for:
    - contao article syndication
    - [Syndication Type Bundle](https://github.com/heimrichhannot/contao-syndication-type-bundle)

> Note: there is no pdf library bundled with this bundle, you need to add the ones you want to use by your own! See Usage section for more information.

Screenshot Configuration
------------------------

[](#screenshot-configuration)

[![](docs/img/screenshot_contao_pdf_configuration.png)](docs/img/screenshot_contao_pdf_configuration.png)

Usage
-----

[](#usage)

### Setup

[](#setup)

1. Install the pdf library you want to use (currently dompdf, mpdf and tcpdf are supported, see [PDF Creator library](https://github.com/heimrichhannot/pdf-creator)) for more information
2. Install bundle with composer or contao manager

    ```
     composer require heimrichhannot/contao-pdf-creator-bundle

    ```
3. Update database
4. Create a pdf configuration in contao backend within system -&gt; pdf configuration or via yaml (see configuration reference)

### Yaml pdf configuration

[](#yaml-pdf-configuration)

To reuse configurations or customize them on different environments, you can set pdf creator configs in your configuration files. You'll find all possible options in the [configuration reference](docs/config-reference.md).

Example:

```
# /config/config.yml
huh_pdf_creator:
  configurations:
    news_export:
      type: dompdf
      name: "Default News export configuration"
      filename: '%%title%%-my_brand_corporate.pdf'
      output_mode: inline
    brand_brochure:
      type: dompdf
      name: "Brand brochure"
      filename: 'my_brand_corporate.pdf'
      output_mode: download
      format: A5
      base_template: 'files/media/brand_cd/brand_brochure_template.pdf'
```

### Export article as pdf

[](#export-article-as-pdf)

1. Set `huh_pdf_creator.enable_contao_article_pdf_syndication` to true

    ```
    # config/config.yml or app/config/config.yml (Contao 4.4)
    huh_pdf_creator:
        enable_contao_article_pdf_syndication: true
    ```
2. Clear cache and update database
3. Choose pdf as syndication option in article configuration and select a pdf configuration

[![](docs/img/screenshow_contao_article_syndication.png)](docs/img/screenshow_contao_article_syndication.png)

### Syndication Bundle

[](#syndication-bundle)

Select PDF syndication and choose the pdf creator setting you want for export.

Advanced topics
---------------

[](#advanced-topics)

### Logging

[](#logging)

To get enhanced debug information while creating pdfs, you can enter the contao dev mode. In dev mode, pdf creator bundle save all logs created by the pdf library (if the library supports PSR-3 logging) to a huh\_pdf\_creator-\[DATE\].log file in the log folder. For dompdf this bundle support the custom logging implementation and stores the log to a huh\_pdf\_creator-dompdf.log file in the log folder.

### Server routing issues / authentication

[](#server-routing-issues--authentication)

To avoid trouble with server routing (special url handling with docker etc.) and use the library on access restricted websites (for example staging setups), you can set a base\_url that will override the url determined from the request and credentials (http basic authentication is supported only). These options are only available with yaml configuration as they usually server-specific.

```
huh_pdf_creator:
  configurations:
    custom_pdf_config:
      type: dompdf
      name: "PDF behind authentication"
      base_url: 'https://customer.example.org'
      credentials: 'user:password'
```

### DomPdf chroot setting

[](#dompdf-chroot-setting)

Pdf Creator Bundle comes with default settings for dompdf chroot option for the most typical folders where files are stored, that are used in pdfs. You can adjust this settings in the bundle configuration.

These are the default settings:

```
huh_pdf_creator:
    allowed_paths:
        - web
        - public
        - files
        - assets
```

Developer
---------

[](#developer)

### Add pdf creator to your bundle

[](#add-pdf-creator-to-your-bundle)

1. Use `PdfGenerator::generate()` to generate a pdf with your content. It expects an id of an PDF Creator config, html content and an `PdfContext` instance and returns a [`PdfCreatorResult`](https://heimrichhannot.github.io/pdf-creator/classes/HeimrichHannot-PdfCreator-PdfCreatorResult.html) instance.

    ```
    use Heimrichhannot\PdfCreatorBundle\Generator\PdfGenerator;
    use Heimrichhannot\PdfCreatorBundle\Generator\PdfGeneratorContext;

    class ExportCustomEntity {
        /**@var PdfGenerator */
        protected $pdfGenerator;

        public function __invoke(string $content, array $row): void {
            $context = new PdfGeneratorContext($row['title']);
            $result = $this->pdfGenerator->generate($content, $row['pdfConfiguration'], $context);

        }
    }
    ```
2. Use `DcaGenerator` to add an PDF Creator config field to your dca.

    ```
    use Contao\CoreBundle\DataContainer\PaletteManipulator;
    use Heimrichhannot\PdfCreatorBundle\Generator\DcaGenerator;

    class LoadDataContainerListener {
        /** @var DcaGenerator */
        protected $dcaGenerator;

        public function __invoke(string $table): void
        {
            if ('tl_custom_dca' === $table) {
                PaletteManipulator::create()->addField('pdfConfiguration', 'someField')->applyToPalette('default', 'tl_custom_entity');
                $GLOBALS['TL_DCA']['tl_custom_entity']['fields']['pdfConfiguration'] = $this->dcaGenerator->getPdfCreatorConfigSelectFieldConfig();
            }
        }
    }
    ```

### Events

[](#events)

EventDescriptionBeforeCreateLibraryInstanceEventPasses the PDF Creator BeforeCreateLibraryInstanceCallbackBeforeOutputPdfCallbackEventPasses the PDF Creator BeforeOutputPdfCallbackMore information
----------------

[](#more-information)

[Configuration reference](docs/configuration_reference.md)

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance55

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% 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 ~96 days

Recently: every ~204 days

Total

18

Last Release

302d ago

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

0.4.10PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/28ad3224d8727b622ebd229840eea6b9dbcb83eb0bd609e6ce65b614830ff538?d=identicon)[digitales@heimrich-hannot.de](/maintainers/digitales@heimrich-hannot.de)

---

Top Contributors

[![koertho](https://avatars.githubusercontent.com/u/12064642?v=4)](https://github.com/koertho "koertho (48 commits)")[![ericges](https://avatars.githubusercontent.com/u/25957923?v=4)](https://github.com/ericges "ericges (4 commits)")

---

Tags

bundlepdfcontao

###  Code Quality

Static AnalysisPHPStan, Rector

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/heimrichhannot-contao-pdf-creator-bundle/health.svg)

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

###  Alternatives

[sulu/sulu

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

1.3k1.4M196](/packages/sulu-sulu)[drupal/core-recommended

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

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

Shopware platform is the core for all Shopware ecommerce products.

585.4M517](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[metamodels/core

MetaModels core

9956.1k68](/packages/metamodels-core)[contao/core-bundle

Contao Open Source CMS

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

PHPackages © 2026

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