public function toText() {
     try {
         $this->pdf->Output($this->fileName.".pdf", "D");
     } catch (Gpf_Exception $e) {
         echo $this->_("Pdf output: %s", $e->getMessage());
     }
 }
 /**
  * @service pdf write
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Action
  */
 public function savePdfFromHtml(Gpf_Rpc_Params $params) {
     $action = new Gpf_Rpc_Action($params);
     $action->setInfoMessage($this->_("Pdf saved"));
     
     if ($action->existsParam('html')) {
         $html = $action->getParam('html');
     } else {
         $action->setErrorMessage($this->_("Html data is not defined"));
         $action->addError();
         return $action;
     }
     
     if ($action->existsParam('fileName')) {
         $fileName = $action->getParam('fileName');
     } else {
         $action->setErrorMessage($this->_("File name is not defined"));
         $action->addError();
         return $action;
     }
     
     htmlspecialchars_decode($html);
     $this->generatePDF($html);
     
     if ($this->savePath != null) {
         if (@is_dir($this->savePath)) {
             chdir($this->savePath);
         } else {
             throw new Gpf_Exception($this->_("Path to save file '%s' not exist", $this->savePath));
         }
     } else {
     	throw new Gpf_Exception($this->_("Path to save file %s is null", $fileName));
     }
     
     try {
         $this->pdf->Output($fileName.".pdf", "F");
     } catch (Gpf_Exception $e) {
     	$action->setErrorMessage($this->_("Unable to create file %s%s.pdf", $this->savePath, $fileName));
     }
     
     $action->addOk();
     
     return $action;
 }