PHPackages                             creativesynergy/silverstripe-wkhtmltopdf - 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. creativesynergy/silverstripe-wkhtmltopdf

Abandoned → [grasenhiller/silverstripe-wkhtmltox](/?search=grasenhiller%2Fsilverstripe-wkhtmltox)Silverstripe-module[PDF &amp; Document Generation](/categories/documents)

creativesynergy/silverstripe-wkhtmltopdf
========================================

Adds the possibility to create PDFs from all DataObjects with WKHTMLTOPDF

1.0.8(8y ago)816.9k↑44.4%5[1 issues](https://github.com/creativeSynergy/silverstripe-wkhtmltopdf/issues)BSD-3-ClausePHP

Since Jan 8Pushed 7y ago2 watchersCompare

[ Source](https://github.com/creativeSynergy/silverstripe-wkhtmltopdf)[ Packagist](https://packagist.org/packages/creativesynergy/silverstripe-wkhtmltopdf)[ Docs](https://github.com/creativeSynergy/silverstripe-wkhtmltopdf)[ RSS](/packages/creativesynergy-silverstripe-wkhtmltopdf/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (10)Used By (0)

**This module is now abandoned, for SilverStripe 4 you can use my new and improved version [silverstripe-wkhtmltox](https://github.com/grasenhiller/silverstripe-wkhtmltox)**

---

Create PDFs in SilverStripe with the power of WKhtmlTOpdf
=========================================================

[](#create-pdfs-in-silverstripe-with-the-power-of-wkhtmltopdf)

This module adds the possibility to simply create PDFs from every DataObject you have. Based on [WKhtmlTOpdf](http://wkhtmltopdf.org/) and [mikehaertl's php wrapper](https://github.com/mikehaertl/phpwkhtmltopdf).

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

[](#installation)

```
$ composer require creativesynergy/silverstripe-wkhtmltopdf
```

Getting started
---------------

[](#getting-started)

1. [WKhtmlTOpdf](http://wkhtmltopdf.org/) must be installed on your server to use this module
2. You'll need to copy the footer.html and header.html files from the module templates folder to `mysite/templates/Pdf/`
3. Create a css file called 'pdf.css' located under `themes/your-theme/css/`

Usage
-----

[](#usage)

#### Basics

[](#basics)

```
$trainer = Trainer::get()->first();
$pdf = new SS_PDF();
$html = $pdf::getHtml($trainer);
$pdf->add($html);
$pdf->save('trainer.pdf');
```

#### Add a cover

[](#add-a-cover)

```
$pdf->add('.../path/to/cover.html', 'Cover');     // You could use the same inputs as listed under "Add pages"
```

#### Add pages

[](#add-pages)

```
$pdf->add('...');                    // Html code
$pdf->add('.../path/to/page.html');               // Html file
$pdf->add('https://www.google.com');              // Website
$pdf->add($pdf::getHtml($dataObject));       // DataObject
```

#### Add specific options for one page

[](#add-specific-options-for-one-page)

```
$options = array(
  'image-quality'     => 100,
  'margin-bottom'     => 0,
  'margin-left'       => 0,
  'margin-right'      => 0,
  'margin-top'        => 0,
  'header-html'       => null,
  'footer-html'       => null
);

$pdf->add('.../path/to/cover.html', 'Cover', $options);
```

All available options can be found [here](http://wkhtmltopdf.org/usage/wkhtmltopdf.txt)

#### Add a page and pass some variables to it

[](#add-a-page-and-pass-some-variables-to-it)

```
$variables = array(
  'Title'             => 'My New Title',
  'MyFreakyWhatever'  => DataObject::get()->byID(123)->WhatEver()
);

$html = $pdf::getHtml($trainer, $variables);

$pdf->add($html);
```

#### Change the page template

[](#change-the-page-template)

```
$html = $pdf::getHtml($trainer, $variables, 'NewPDFTemplate');
$pdf->add($html);
```

By default the module will look for a template called "ClassName\_pdf"

#### Preview in browser

[](#preview-in-browser)

```
$pdf->preview();
```

#### Save

[](#save)

```
$pdf->save('trainer.pdf');                        // This will also return an file instance to work with
```

#### Specify the folder to save in

[](#specify-the-folder-to-save-in)

```
$pdf->setFolderName('trainers/pdfs');
```

#### Download

[](#download)

```
$pdf->download('trainer.pdf');
```

Global options
--------------

[](#global-options)

#### Set the global options used for all pages in this pdf

[](#set-the-global-options-used-for-all-pages-in-this-pdf)

```
$css = BASE_PATH . '/themes/' . SSViewer::current_theme() . '/css/pdf.css';
$header = BASE_PATH . '/mysite/templates/Pdfs/header.html';
$footer = BASE_PATH . '/mysite/templates/Pdfs/footer.html';

$options = array(
  'enable-javascript',
  'dpi'               => 150,
  'image-dpi'         => 150,
  'image-quality'     => 100,
  'user-style-sheet'  => $css,
  'header-html'       => $header,
  'footer-html'       => $footer,
  ...
  ...
);

$pdf->setGlobalOptions($options);
```

#### Set or modifiy only one global option

[](#set-or-modifiy-only-one-global-option)

```
$pdf->setOption('enable-javascript');

$pdf->setOption('dpi', '300');

$pdf->setOption('run-script', array(
  '../path/to/local/script1.js'
));

$pdf->setOption('replace', array(
  '{whatever}' => 'something new'
));
```

#### Remove one global option

[](#remove-one-global-option)

```
$pdf->removeOption('replace');
```

Templates, Header &amp; Footer and Styling
------------------------------------------

[](#templates-header--footer-and-styling)

#### Page template

[](#page-template)

If your page ist based on an DataObject and you generate the html with the $pdf::getHtml() function, you'll be able to set a specific template to use for this page by passing it as third parameter to the function (without the .ss ending!). By default, the module will search for a template called "Classname\_pdf".

#### Header &amp; Footer

[](#header--footer)

WKhtmlTOpdf let you specify seperate files for your pdf's header and footer section. By default they are located under `mysite/templates/Pdf/header.html` and `mysite/templates/Pdf/footer.html`.

You can change the location of those files or remove the header and/or footer completely by changing the global or page specific options.

```
$pdf->setOption('header-html', '/path/to/header.html');
$pdf->removeOption('footer-html');
```

Demo Pdf.ss, header.html and footer.html files are included to get you started

#### Styling

[](#styling)

Thanks to WKhtmlTOpdf you have full CSS3 and HTML5 support and will be able to do fancy things "without" the limitations you'll have to face while using other tools like dompdf or tcpdf. You can even use javascript to modify your pages.

By default the module requires a pdf.css in under themes/your-theme/css/pdf.css You can change this by setting the global or page specific option

```
$pdf->setOption('user-style-sheet', '/path/to/pdf.css');
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~99 days

Recently: every ~115 days

Total

9

Last Release

2989d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9002671?v=4)[Benedikt Hofstätter](/maintainers/bhofstaetter)[@bhofstaetter](https://github.com/bhofstaetter)

---

Top Contributors

[![CreativeSynergy](https://avatars.githubusercontent.com/u/193625707?v=4)](https://github.com/CreativeSynergy "CreativeSynergy (20 commits)")[![bhofstaetter](https://avatars.githubusercontent.com/u/9002671?v=4)](https://github.com/bhofstaetter "bhofstaetter (12 commits)")[![a2nt](https://avatars.githubusercontent.com/u/672794?v=4)](https://github.com/a2nt "a2nt (1 commits)")[![bahuma20](https://avatars.githubusercontent.com/u/5746121?v=4)](https://github.com/bahuma20 "bahuma20 (1 commits)")[![Taitava](https://avatars.githubusercontent.com/u/13002142?v=4)](https://github.com/Taitava "Taitava (1 commits)")

---

Tags

pdfwkhtmltopdfsilverstripe

### Embed Badge

![Health badge](/badges/creativesynergy-silverstripe-wkhtmltopdf/health.svg)

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

###  Alternatives

[nitmedia/wkhtml2pdf

Html 2 Pdf - using wkhtml2pdf, work on 32bit and 64 bit linux + MacOS

117300.3k1](/packages/nitmedia-wkhtml2pdf)[lucasromanojf/laravel5-pdf

Provides the HTML2PDF functionality using the wkhtmltopdf library (Laravel 5)

1271.8k](/packages/lucasromanojf-laravel5-pdf)[symbiote/silverstripe-pdfrendition

A module that makes use of the Flying Saucer XHTML renderer project to create PDFs from XHTML pages.

175.0k](/packages/symbiote-silverstripe-pdfrendition)

PHPackages © 2026

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