PHPackages                             mattclegg/silverstripe-dompdf - 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. mattclegg/silverstripe-dompdf

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

mattclegg/silverstripe-dompdf
=============================

7302[2 issues](https://github.com/mattclegg/silverstripe-dompdf/issues)PHPCI failing

Since May 21Pushed 5y ago2 watchersCompare

[ Source](https://github.com/mattclegg/silverstripe-dompdf)[ Packagist](https://packagist.org/packages/mattclegg/silverstripe-dompdf)[ RSS](/packages/mattclegg-silverstripe-dompdf/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

PDF Generation via DOMPDF Library
=================================

[](#pdf-generation-via-dompdf-library)

Input:

- HTML string (which could be rendered template)
- HTML File

Output

- PDF File location
- SS File
- PDF binary stream to browser

Quickly getting started
-----------------------

[](#quickly-getting-started)

Find the ID number of a page (ie 1) and go to; /pdf/1

Customize your tempalte by copying DefaultPDF to your theme directory.

View raw output by going to; /pdf/1?show

Example usage
-------------

[](#example-usage)

```
$pdf = new SS_DOMPDF();
$pdf->setHTML($mydataobject->renderWith('MyTemplate'));
$pdf->render();
$pdf->toFile('mypdf.pdf');

```

Debugging
---------

[](#debugging)

The $pdf-&gt;streamdebug(); function is useful for quickly viewing pdfs, particularly if your browser supports displaying pdfs, rather than downloading.

You can check your html before it is converted like this:

```
echo $mydataobject->renderWith('MyTemplate');die();

```

Once this has been installed then you need to; parse your PDF templates to a .html file get dompdf to convert the saved .html file

A more advanced solution would be something like;

class CustomPage\_Controller extends Page\_Controller {

```
public function mypdf(){
	if($member = Member::currentUser()){
		Requirements::clear();

		if(!file_exists(ASSETS_PATH."/private")) mkdir(ASSETS_PATH."/private");

		require_once 'Zend/Date.php';
		$defaultDateFormat =Zend_Date::now()->toString($member->DateFormat);
		$defaultTimeFormat = Zend_Date::now()->toString($member->TimeFormat);

		$content = $this->customise(array(
			'Member'	=> $member
		))->renderWith(array('pdf'));

		$filename=ASSETS_PATH."/private/current-pdf-{$member->ID}.html";
		$baseFile = preg_replace('/\\.pdf$/','',$filename);

		$fh = fopen($baseFile, "w+") or user_error("Couldn't open $baseFile.html for writing", E_USER_ERROR);
		fwrite($fh, $content) or user_error("Couldn't write content to $baseFile.html", E_USER_ERROR);
		fclose($fh);

		$dompdf = new SS_DOMPDF();
		$dompdf->load_html_file(ASSETS_PATH."/private/current-pdf-{$member->ID}.html");

		if ( isset($base_path) ) {$dompdf->set_base_path($base_path);}

		$paper = DOMPDF_DEFAULT_PAPER_SIZE;
		$orientation = "portrait";

		$dompdf->set_paper($paper, $orientation);
		$dompdf->render();

		$outfile = substr("{$member->FullName()}_{$defaultDateFormat}_{$defaultTimeFormat}", 0, 250).".pdf";

		$dompdf->stream(Convert::raw2xml($outfile));
	}
}

/**
* You may also like this 'test' function
**/
public function testpdf(){
	if($member = Member::currentUser()){
		Requirements::clear();
		require_once 'Zend/Date.php';
		$defaultDateFormat =Zend_Date::now()->toString($member->DateFormat);
		$defaultTimeFormat = Zend_Date::now()->toString($member->TimeFormat);

		$property=$member->SavedProperty();
		$content = $this->customise(array(
			'Member'	=> $member
		))->renderWith(array('pdf'));
		return $content;
	}
}

```

}

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/00cc44a744aaaa61ffe0d0c1cf21702f0ad5c0fca2ca50d3338461f1dd6e3113?d=identicon)[mattclegg](/maintainers/mattclegg)

---

Top Contributors

[![mattclegg](https://avatars.githubusercontent.com/u/303487?v=4)](https://github.com/mattclegg "mattclegg (10 commits)")

### Embed Badge

![Health badge](/badges/mattclegg-silverstripe-dompdf/health.svg)

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

###  Alternatives

[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.2k57.6M131](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)[setasign/tfpdf

This class is a modified version of FPDF that adds UTF-8 support. The latest version is based on FPDF 1.85.

426.1M30](/packages/setasign-tfpdf)[aspera/xlsx-reader

Spreadsheet reader library for XLSX files

52742.2k5](/packages/aspera-xlsx-reader)

PHPackages © 2026

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