<?php
  
  // This code adds a basic DOMPDF footer call to a page.
  
  // This code takes the output buffer's contents
  // created in the DOMPDF Single Page Header Include
  // code block and outputs a PDF to the browser or prompts for download.
  
  // capture output buffer, turn off buffering
  $html = ob_get_flush();
  
  // erases the buffer, turns it off
  ob_clean ();

  use Dompdf\Dompdf;
  use Dompdf\Options;
  
  
  // Options
  $options = new Options();
  $options->set('isHtml5ParserEnabled', true);
  
  $options->set('chroot', './'); // Else Images Do Not Work.

  
  $dompdf = new DOMPDF($options);
  
  // document size
  
  $width = '';
  $height = '';
  
  if($width != "" && $height != ""){
  	$dompdf->setPaper(array(0,0,$width,$height));
  } else {
  	$dompdf->setPaper('letter', 'portrait');
  }

  $dompdf->loadHtml($html);
  
  // $_dompdf_warnings contains all parse errors
  // To see any such items, uncomment the next line.
  //print_r($_dompdf_warnings); die;
  
  $dompdf->render();
  
  $dompdf->stream("Form Page.pdf", array('compress' => 1, 'Attachment'=>0));
  
  // Optional
  //clear_fb_session();

?>