function init()
 {
     if (is_null(self::$__connection)) {
         $con_str = "host=" . DB_HOST . " dbname=" . self::DB_NAME . " user=" . self::DB_USER . " password=" . self::DB_PASS;
         if (!(self::$__connection = pg_connect($con_str))) {
             throw new Exception("Database connection failed.");
         }
     }
 }
 function output($options = null)
 {
     // Store the last page in the page cache
     if (!is_null($this->_current_page_id)) {
         $this->_pdf->close_object();
         $this->_pdf->add_object($this->_current_page_id, "add");
         Page_Cache::store_page($this->_cache_id, $this->_pdf->get_page_number(), $this->_pdf->serialize_object($this->_current_page_id));
         $this->_current_page_id = null;
     }
     return $this->_pdf->output();
 }
 function &output()
 {
     if (!is_null($this->_current_page_id)) {
         $this->_pdf->close_object();
         $this->_pdf->add_object($this->_current_page_id, "add");
         Page_Cache::store_page($this->_cache_id, $this->_pdf->get_page_number(), $this->_pdf->serialize_object($this->_current_page_id));
         $this->_current_page_id = null;
     }
     return $this->_pdf->output();
 }