Generating PDFs with DOMPDF

Here is my steps of usage DOMPDF( with Seagull, for rendering HTML articles (publisher):

  • make dir: lib/other/Dompdf
  • Copy files from dompdf to Dompdf:
  • Configure Seagull to use "lib/other" as additional include path:

General -> Configuration -> Additional include paths

  • Sample. Modified FileMgr from publisher/classes
  • Required includes (before class declaration):
require_once SGL_CORE_DIR . '/Item.php';
require_once 'Dompdf/';
  • Modify "validate" function (just place to the end of function):
$input->articleID = (int)$req->get('frmArticleID');
  • Add new method:
   function _cmd_downloadPdf(&$input, &$output)
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       $aArticleDetail = SGL_Item::getItemDetail($input->articleID);
       $dompdf = new DOMPDF();
  • Use {makeUrl()} with your templates, for example:

Or just type in address bar of your web browser(quick test):


This way can be easy adopted for usage with cms or any other module, but in summary it's yet another way to handle "html 2 pdf" request.

Autoload Issue

Fatal error: require_once() [function.require]: Failed opening required '/trunk/lib/other/Dompdf/include/html_template_flexy_token_doctype.cls.php'

Solution - Add a check for the include file in, change from:

function DOMPDF_autoload($class) {
  $filename = mb_strtolower($class) . ".cls.php";
  require_once(DOMPDF_INC_DIR . "/$filename");


function DOMPDF_autoload($class) {
  $filename = mb_strtolower($class) . ".cls.php";
  if(file_exists(DOMPDF_INC_DIR . "/$filename")) {
      require_once(DOMPDF_INC_DIR . "/$filename");