PHPackages                             pmarien/html-to-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. pmarien/html-to-pdf-bundle

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

pmarien/html-to-pdf-bundle
==========================

Symfony integration for pmarien/html-to-pdf

1.0.0(2y ago)048MITPHPPHP &gt;=8.1

Since Feb 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/pmarien/Symfony-html-to-pdf)[ Packagist](https://packagist.org/packages/pmarien/html-to-pdf-bundle)[ RSS](/packages/pmarien-html-to-pdf-bundle/feed)WikiDiscussions main Synced today

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

pmarien/html-to-pdf-bundle
==========================

[](#pmarienhtml-to-pdf-bundle)

Symfony integration for pmarien/html-to-pdf

1. Requirements
2. How to install?
3. How to configure?
4. How to use internal assets?
5. How to use?
    1. Controller (Inline PDF)
    2. Controller (Download PDF)
    3. Controller (Store PDF file)
    4. With Twig Templates
        1. Controller (Inline PDF)
        2. Controller (Download PDF)
        3. Controller (Store PDF file)

Requirements
------------

[](#requirements)

The bundle requires PHP in version 8.1 or higher and Symfony in version 5, 6 or 7.

The html-to-pdf-library requires implementations of `psr/http-message`, `psr/http-factory` and `psr/http-client`.

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

[](#how-to-install)

The bundle should be installed via composer: `pmarien/html-to-pdf`.

```
composer req pmarien/html-to-pdf
```

How to configure?
-----------------

[](#how-to-configure)

If you want to configure the bundle you should add the file `config/packages/html_to_pdf.yaml`.

Without api key configuration the bundle will act as anonymous client, which leads to a limit of 3 generated PDF files per day.

```
html_to_pdf:
  apiKey: 'YOUR_API_KEY'
  assetScheme: 'http' #optional to use a different asset location
  assetHost: 'example.com' #optional to use a different asset location
```

How to use internal assets?
---------------------------

[](#how-to-use-internal-assets)

If you want to use assets in your pdf, they have to be public accessible via http for the pdf generator. Sometimes you want to use the assets, but don't want to publish them. For those cases, this bundle comes with an AssetAccessController, which requires a hash for file protection.

The routing have to be enabled via config (`config/routes/html_to_pdf.yaml`):

```
HtmlToPdfBundle:
  resource: '@HtmlToPdfBundle/Resources/config/routes.xml'
```

Asset uris can be build manually (route name: `html_to_pdf_get_file`, required parameters: `filename` and `hash`) or via twig filter:

```

```

If you build uris manually, the hash can be generated via `PMA\HtmlToPdfBundle\Asset\AssetAccessorInterface::getHash`(available as symfony service).

How to use?
-----------

[](#how-to-use)

If you want to generate pdf files directly from html, you should use `PMA\HtmlToPdfBundle\Bridge\FoundationBridge` as generator. It's available as service in the service container and may be autowired by symfony's dependency injection.

### Controller (Inline PDF)

[](#controller-inline-pdf)

```
public function showAction(\PMA\HtmlToPdfBundle\Bridge\FoundationBridge $generator):\Symfony\Component\HttpFoundation\Response{
   return $generator->inlineResponse(
        'test.pdf',
        'This is a test!'
    );
}
```

### Controller (Download PDF)

[](#controller-download-pdf)

```
public function downloadAction(\PMA\HtmlToPdfBundle\Bridge\FoundationBridge $generator):\Symfony\Component\HttpFoundation\Response{
   return $generator->attachmentResponse(
        'test.pdf',
        'This is a test!'
    );
}
```

### Service (Store PDF file)

[](#service-store-pdf-file)

```
public function storeFile(\PMA\HtmlToPdfBundle\Bridge\FoundationBridge $generator):void {
    $generator->createFile(
        '/your/project/file-storage/test.pdf',
        'This is a test!'
    );
}
```

### Twig

[](#twig)

If you want to generate pdf files from twig templates, you should use `PMA\HtmlToPdfBundle\Bridge\TwigBridge` as generator. It's available as service in the service container and may be autowired by symfony's dependency injection. It requires Twig to be installed in your project.

#### Controller (Inline PDF file)

[](#controller-inline-pdf-file)

```
public function showAction(\PMA\HtmlToPdfBundle\Bridge\TwigBridge $generator):\Symfony\Component\HttpFoundation\Response{
   return $generator->inlineResponse(
        'test.pdf',
         'pdf-templates/test.pdf.twig',
        [
            'test'=>'Test'
        ]
    );
}
```

#### Controller (Download PDF file)

[](#controller-download-pdf-file)

```
public function downloadAction(\PMA\HtmlToPdfBundle\Bridge\TwigBridge $generator):\Symfony\Component\HttpFoundation\Response{
   return $generator->attachmentResponse(
        'test.pdf',
         'pdf-templates/test.pdf.twig',
        [
            'test'=>'Test'
        ]
    );
}
```

#### Service (Store PDF file)

[](#service-store-pdf-file-1)

```
public function storeFile(\PMA\HtmlToPdfBundle\Bridge\TwigBridge $generator):void {
    $generator->createFile(
        '/your/project/file-storage/test.pdf',
        'pdf-templates/test.pdf.twig',
        [
            'test'=>'Test'
        ]
    );
}
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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

875d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21ec4e897f4ee0a0d0bcaf844242946502ff852e9bee8fb2e1ef9a2fc2fb5f16?d=identicon)[pmarien](/maintainers/pmarien)

---

Top Contributors

[![pmarien](https://avatars.githubusercontent.com/u/8394874?v=4)](https://github.com/pmarien "pmarien (9 commits)")

### Embed Badge

![Health badge](/badges/pmarien-html-to-pdf-bundle/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[shopware/platform

The Shopware e-commerce core

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

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k17.8k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[shopware/administration

Administration frontend for the Shopware Core

414.3M116](/packages/shopware-administration)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

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