public function PdfDownloadAction()
 {
     $session = new Zend_Session_Namespace('login');
     $cryptoID = $this->_hasParam('cryptoID') ? $this->_getParam('cryptoID') : null;
     $pageHeadersAll = $this->_hasParam('pageHeader') ? $this->_getParam('pageHeader') : array();
     $pageHeaders = array();
     while (list($key, $val) = each($pageHeadersAll)) {
         if (isset($val[pdf]) && $val[pdf] == 1) {
             $pageHeaders[] = $key;
         }
     }
     if ($this->_hasParam('download') && isset($session->tempFile)) {
         if (isset($cryptoID) && $cryptoID != 0) {
             $this->view->cryptoID = $cryptoID;
         }
         $this->view->pdf = file_get_contents($session->tempFile);
         unlink($session->tempFile);
         unset($session->tempFile);
     } else {
         $instance = new InstanceModel(array('instanceID' => $session->dataInstanceID, 'depth' => 'instance'));
         $html = $instance->xml2html($pageHeaders);
         $dompdf = new DOMPDF();
         $dompdf->load_html($html);
         $dompdf->render();
         $pdf = $dompdf->output();
         if (isset($cryptoID) && $cryptoID != 0) {
             $crypto = new CryptoModel(array('cryptoID' => $cryptoID));
             $pdf = $crypto->encrypt($pdf);
             $this->view->cryptoID = $cryptoID;
         }
         $tempFile = tempnam(PROJECT_PATH . DIRECTORY_SEPARATOR . 'tmp', 'exp');
         file_put_contents($tempFile, $pdf);
         $session->tempFile = $tempFile;
     }
     $this->view->setRenderLayout(false);
 }