3dgoo/silverstripe-dompdf

Silverstripe PDF Generation via DOMPDF Library



Documentation

Silverstripe DOMPDF

This module provides PDF generation through the DOMPDF library for Silverstripe.

This is a fork of:

Makes use of: https://github.com/dompdf/dompdf Dompdf websites: http://dompdf.github.com/, http://pxd.me/dompdf/www/

Input:

  • HTML string (which could be a rendered template)
  • HTML File

Output

  • PDF file location
  • SS file
  • PDF binary stream to browser

Installation (with composer)

$ composer require 3dgoo/silverstripe-dompdf

Example usage

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

Debugging

The $pdf->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();

Useful Tips