PHPackages                             atwx/silverstripe-headless-pdf - 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. atwx/silverstripe-headless-pdf

ActiveSilverstripe-vendormodule[PDF &amp; Document Generation](/categories/documents)

atwx/silverstripe-headless-pdf
==============================

Headless Chrome PDF generation for SilverStripe

024PHP

Since May 4Pushed 1mo agoCompare

[ Source](https://github.com/atwx/silverstripe-headless-pdf)[ Packagist](https://packagist.org/packages/atwx/silverstripe-headless-pdf)[ RSS](/packages/atwx-silverstripe-headless-pdf/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Silverstripe Headless PDF
=========================

[](#silverstripe-headless-pdf)

A Silverstripe module for printing a given html-template into a pdf file using [headless chromium](https://github.com/chrome-php/chrome) in php. This module enables the creation of zugferd compatible e-invoices. For this the additional module [horstoeko/zugferd](https://github.com/horstoeko/zugferd) is required.

Installation
------------

[](#installation)

This module can be installed via Composer with

```
composer require atwx/silverstripe-headless-pdf

```

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

[](#requirements)

This module requires the following modules

```
php: "^8.3",
silverstripe/framework: "^6.0",
chrome-php/chrome: "^1.15"

```

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

[](#configuration)

The browser-factory will search for the environment variable `CHROME_PATH` when starting. To prevent it from guessing, this variable should be set in your `.env` ([configuration instruction from chrome-php/chrome](https://github.com/chrome-php/chrome?tab=readme-ov-file#using-different-chrome-executable)).

If the browser has trouble rendering the PDF (mostly timeouts), you can try different navigation wait events. This can be set in the `WAITING_MODE` variable in the `.env`. All available events can be found [here](https://github.com/chrome-php/chrome#navigate-to-an-url). For each constant the string version has to be used. In this module the default value is `'networkIdle'`.

This pdf module uses hashes created with the `sha256` algorithm for protecting the html. Therefore you need to set the `HEADLESS_PDF_HASH_KEY` variable in your `.env` otherwise the pdf creation return an 403 http error. Any other authentication method has to be disabled for the `HeadlessPDFController->renderPdfTemplate` function.

Additionally if you are using ddev you can set the `IS_DDEV` variable in your `.env` to `"true"`. By doing this sandboxing is disabled and certificate errors are ignored allowing printing PDFs locally. To use headless chrome in ddev you need the [headless chrome add-on](https://addons.ddev.com/addons/gebruederheitz/ddev-headless-chrome) by gebruederheitz.

Usage
-----

[](#usage)

To print a pdf you need to create a new instance of `HeadlessPDFService` and call its `generatePdf` function. This function takes up to 5 arguments:

- a link for rendering the html-template which will then be printed as a pdf,
- a string containing the filename,
- a bool `getPath` for getting the pdf as a string (default) or as a path to a temporary file,
- optional xml-data for creating zugferd compatible e-invoices (this requires additionally the [horstoeko/zugferd](https://github.com/horstoeko/zugferd) module),
- and an optional array for [php-chrome options](https://github.com/chrome-php/chrome?tab=readme-ov-file#print-as-pdf) changing the default pdf-options defined in the `HeadlessPDFService`.

The link given as first argument needs to point to

```
/pdf/renderPdfTemplate/

```

calling the `HeadlessPDFController` with the following get-parameters:

- `template` containing the full template name/path (called with renderWith($template)),
- `hash` generated with `HeadlessPDFController::generateHash`,
- optional `className` to use an object in the template corresponding to $ID in the link. This object is callable as `$TemplateObject` in the template,
- optional `controller` to use an iterable list of dataobjects in the template callable as `$TemplateDatalist`. This list can be defined in a getPdfDatalist function in the given controller,
- optional `variation` containing a string callable as `Variation` in the template to enable similar pdf versions without the need to create a new template.

For the correct rendering of the pdf received as a string you need to set the two HTTP-headers

```
$this->getResponse()->addHeader('Content-Type', 'application/pdf')
$this->getResponse()->addHeader('Content-Disposition', 'inline; filename="' .  . '.pdf"')

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance61

Regular maintenance activity

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 81.8% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/64d979993815fa2d2ea95b3fd72b4f43e95a631ce569f4f1c0330786971b5fc2?d=identicon)[adiwidjaja](/maintainers/adiwidjaja)

![](https://www.gravatar.com/avatar/63d164bab71fc011430a89319c7e170995fa494d7d122feaed5a370f39c89d12?d=identicon)[HenrikBormann](/maintainers/HenrikBormann)

---

Top Contributors

[![HenrikBormann](https://avatars.githubusercontent.com/u/88386045?v=4)](https://github.com/HenrikBormann "HenrikBormann (9 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (2 commits)")

### Embed Badge

![Health badge](/badges/atwx-silverstripe-headless-pdf/health.svg)

```
[![Health](https://phpackages.com/badges/atwx-silverstripe-headless-pdf/health.svg)](https://phpackages.com/packages/atwx-silverstripe-headless-pdf)
```

###  Alternatives

[qipsius/tcpdf-bundle

A bundle to easily integrate TCPDF into Symfony

23749.5k](/packages/qipsius-tcpdf-bundle)[radnan/rdn-csv

Laminas module to export and import CSV files

19119.3k](/packages/radnan-rdn-csv)[nilgems/laravel-textract

A Laravel package to extract text from files like DOC, XL, Image, Pdf and more. I've developed this package by inspiring "npm textract".

195.7k](/packages/nilgems-laravel-textract)[akeneo-labs/excel-connector-bundle

Akeneo PIM Excel connector bundle

166.4k](/packages/akeneo-labs-excel-connector-bundle)

PHPackages © 2026

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