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 6y 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 3w 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 9% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

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://avatars.githubusercontent.com/u/303487?v=4)[Matt Clegg](/maintainers/mattclegg)[@mattclegg](https://github.com/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

[tarfin-labs/easy-pdf

Makes pdf processing easy.

1719.9k](/packages/tarfin-labs-easy-pdf)

PHPackages © 2026

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