PHPackages                             heyday/silverstripe-wkhtml - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. heyday/silverstripe-wkhtml

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

heyday/silverstripe-wkhtml
==========================

Provides Wkhtml functionality in SilverStripe

3.0.0(2y ago)1538.7k—5%91MITPHP

Since Nov 1Pushed 2y ago25 watchersCompare

[ Source](https://github.com/heyday/silverstripe-wkhtml)[ Packagist](https://packagist.org/packages/heyday/silverstripe-wkhtml)[ RSS](/packages/heyday-silverstripe-wkhtml/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (12)Used By (1)

Silverstripe Wkhtml - by Heyday
===============================

[](#silverstripe-wkhtml---by-heyday)

This module provides a SilverStripe-centric wrapper for [Snappy](https://github.com/KnpLabs/snappy) and [wkhtml](http://code.google.com/p/wkhtmltopdf/).

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

[](#requirements)

- [Wkhtml binary](http://code.google.com/p/wkhtmltopdf/downloads/list) either wkhtmltopdf or wkhtmltoimage

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

[](#installation)

```
$ composer require "heyday/silverstripe-wkhtml"

```

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

[](#how-to-use)

Four things are required to generate a pdf or an image:

- `Knp\Snappy\GeneratorInterface` The wrapper for wkhtmltopdf or wkhtmltoimage
- `Heyday\SilverStripe\WkHtml\Input\InputInterface` to provide the html
- `Heyday\SilverStripe\WkHtml\Output\OutputInterface` output the pdf or image in different ways
- `Heyday\SilverStripe\WkHtml\Generator` to glue everything together

### Available Inputs

[](#available-inputs)

- Request (generates content from a request)
- TextString (content is specified by a string)
- Template (generates content from a SilverStripe template)
- Url (generates content from a GET request to a Url)
- Viewer (generates content from an SSViewer instance)

### Available Outputs

[](#available-outputs)

- Browser (outputs to the browser)
- File (outputs to a file)
- RandomFile (outputs to a random filename)
- TextString (outputs to a string)

### Available Generators

[](#available-generators)

- Pdf
- Image

Examples
--------

[](#examples)

### Full example (from a controller action)

[](#full-example-from-a-controller-action)

```
SilverStripe\Core\Injector\Injector:
  # Create PDF generator as an injector service
  # This allows you to specify the binary path once and have it set up
  # automatically by getting the service from the injector.
  Knp\Snappy\Pdf:
    constructor:
      - '/bin/wkhtmltopdf' # Path to your WKTHMLTOPDF binary. Use '`SOME_ENV_VAR`' to define the binary path in .env
```

```
use Heyday\SilverStripe\WkHtml;
use SilverStripe\Core\Injector\Injector;

$generator = WkHtml\Generator::create(
    // Use Injector->get(Pdf::class) if you don't need to modify options
    // Use Injector->create() to create a transient service for modifications (e.g. setOption)
    // Using Injector->get() and making changes will cause changes to be made for all uses of get(Pdf::class) for the entire request
    Injector::inst()->create(\Knp\Snappy\Pdf::class),
    WkHtml\Input\Url::create('/'),
    WkHtml\Output\Browser::create('test.pdf', 'application/pdf')
);
return $generator->process();
```

### Inputs

[](#inputs)

#### Request

[](#request)

```
\Heyday\SilverStripe\WkHtml\Input\Request::create(
    // Controller::curr()->getRequest() is also an option
    Injector::inst()->get(\SilverStripe\Control\HTTPRequest::class)
);
```

```
\Heyday\SilverStripe\WkHtml\Input\Request::create(
    Injector::inst()->get(\SilverStripe\Control\HTTPRequest::class),
    new Session([
        'arg' => 'value',
    ])
);
```

#### String

[](#string)

```
$html =  'Hello',
    ]
);

\Heyday\SilverStripe\WkHtml\Input\Template::create(
    'MyTemplate',
    ArrayData::create([
        'Var' => 'Hello',
    ])
);

\Heyday\SilverStripe\WkHtml\Input\Template::create(
    '$Var World',
    ArrayData::create([
        'Var' => 'Hello',
    ]),
    true
);
```

#### Viewer

[](#viewer)

```
\Heyday\SilverStripe\WkHtml\Input\Viewer::create(
    SSViewer::create([
        'Template',
    ]),
    ArrayData::create([
        'Var' => 'Hello',
    ])
);
```

#### Url

[](#url)

```
\Heyday\SilverStripe\WkHtml\Input\Url::create('/');

\Heyday\SilverStripe\WkHtml\Input\Url::create('http://google.co.nz/');
```

### Outputs

[](#outputs)

#### Browser

[](#browser)

```
\Heyday\SilverStripe\WkHtml\Output\Browser::create('test.pdf', 'application/pdf'); // Force download

\Heyday\SilverStripe\WkHtml\Output\Browser::create('test.pdf', 'application/pdf', true); // Embeds
```

#### File

[](#file)

```
\Heyday\SilverStripe\WkHtml\Output\File::create(BASE_PATH . '/test.pdf');

\Heyday\SilverStripe\WkHtml\Output\File::create(BASE_PATH . '/test.pdf', true); // Overwrite
```

#### Random File

[](#random-file)

```
\Heyday\SilverStripe\WkHtml\Output\RandomFile::create(BASE_PATH);
```

#### String

[](#string-1)

```
\Heyday\SilverStripe\WkHtml\Output\TextString::create();
```

Unit Testing
------------

[](#unit-testing)

```
$ composer install
$ phpunit
```

License
-------

[](#license)

This project is licensed under an MIT license

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 66.2% 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 ~404 days

Recently: every ~589 days

Total

11

Last Release

906d ago

Major Versions

1.1.1 → 2.0.0-beta12019-01-09

2.x-dev → 3.0.02023-11-24

PHP version history (2 changes)1.1.0PHP ^7.0

2.0.0-beta1PHP &gt;=5.6

### Community

Maintainers

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

---

Top Contributors

[![camspiers](https://avatars.githubusercontent.com/u/51294?v=4)](https://github.com/camspiers "camspiers (45 commits)")[![hchokshi](https://avatars.githubusercontent.com/u/10136407?v=4)](https://github.com/hchokshi "hchokshi (11 commits)")[![wilr](https://avatars.githubusercontent.com/u/101629?v=4)](https://github.com/wilr "wilr (4 commits)")[![glenn-bautista](https://avatars.githubusercontent.com/u/375172?v=4)](https://github.com/glenn-bautista "glenn-bautista (4 commits)")[![stecman](https://avatars.githubusercontent.com/u/2230769?v=4)](https://github.com/stecman "stecman (2 commits)")[![tractorcow](https://avatars.githubusercontent.com/u/936064?v=4)](https://github.com/tractorcow "tractorcow (1 commits)")[![stevie-mayhew](https://avatars.githubusercontent.com/u/1953220?v=4)](https://github.com/stevie-mayhew "stevie-mayhew (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/heyday-silverstripe-wkhtml/health.svg)

```
[![Health](https://phpackages.com/badges/heyday-silverstripe-wkhtml/health.svg)](https://phpackages.com/packages/heyday-silverstripe-wkhtml)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[silverstripe/multi-domain

Allows multiple domains to access one CMS instance, mapping them to different sections of the hierarchy

141.6k](/packages/silverstripe-multi-domain)

PHPackages © 2026

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