diff --git a/plugins/ktstandard/PDFGeneratorAction.php b/plugins/ktstandard/PDFGeneratorAction.php index 76d081b..e99c333 100644 --- a/plugins/ktstandard/PDFGeneratorAction.php +++ b/plugins/ktstandard/PDFGeneratorAction.php @@ -255,9 +255,10 @@ class PDFGeneratorAction extends KTDocumentAction { $converter->setDocument($this->oDocument); $res = $converter->processDocument(); - if(!$res){ + if($res !== true){ + // please contact your System Administrator $default->log->error('PDF Generator: PDF file could not be generated'); - $this->errorRedirectToMain(_kt('PDF file could not be generated, the file may be of an unsupported mime type or the PDF Generator could not connect.')); + $this->errorRedirectToMain($res . ' ' . _kt('Please contact your System Administrator for assistance.')); exit(); } @@ -268,7 +269,22 @@ class PDFGeneratorAction extends KTDocumentAction { } exit(); } - $this->errorRedirectToMain(_kt('PDF file could not be generated')); + + // Check if this is a office 2007 doc + $mime = $this->getMimeExtension(); + + $o2007_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; + $o2007_types[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; + $o2007_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + + if(in_array($mime, $o2007_types)){ + $error = _kt('The document is an MS Office 2007 format. This may not be supported by your version of OpenOffice. Please contact your System Administrator for assistance'); + $default->log->error('PDF Generator: Document is an MS Office 2007 format. OpenOffice must be version 3.0 or higher to support this format. Please upgrade to the latest version.'); + }else{ + $error = _kt('PDF file could not be generated. The format may not be supported by your version of OpenOffice. Please contact your System Administrator for assistance'); + $default->log->error('PDF Generator: PDF file could not be generated. The format may not be supported by your version of OpenOffice. Please check that you have the latest version installed.'); + } + $this->errorRedirectToMain($error); exit(); } diff --git a/plugins/pdfConverter/pdfConverter.php b/plugins/pdfConverter/pdfConverter.php index bb2c38f..7068177 100644 --- a/plugins/pdfConverter/pdfConverter.php +++ b/plugins/pdfConverter/pdfConverter.php @@ -48,6 +48,25 @@ class pdfConverter extends BaseProcessor $this->ooPort = $config->get('openoffice/port','8100'); $this->xmlrpc = XmlRpcLucene::get($javaServerUrl); + + + + } + + /** + * Check that open office is running + * + * @return boolean + */ + private function checkOO() + { + $available = SearchHelper::checkOpenOfficeAvailablity(); + + if(is_null($available)){ + return true; + } + + return false; } /** @@ -63,17 +82,26 @@ class pdfConverter extends BaseProcessor if(!file_exists($path)){ global $default; - $default->log->debug('Document, id: '.$this->document->iId.', does not exist at given storage path: '.$path); - return false; + $default->log->debug('PDF Converter: Document, id: '.$this->document->iId.', does not exist at given storage path: '.$path); + return _kt("The document, id: {$this->document->iId}, does not exist at the given storage path: {$path}"); } + // check for OO + $available = $this->checkOO(); + // do pdf conversion + if(!$available){ + global $default; + $default->log->error("PDF Converter: Cannot connect to Open Office Server on host {$this->ooHost} : {$this->ooPort}"); + return _kt('Cannot connect to Open Office Server.'); + } + $res = $this->convertFile($path, $ext); - if($res === false){ + if($res !== true){ global $default; - $default->log->debug('Document, id: '.$this->document->iId.', could not be converted to pdf.'); - return false; + $default->log->debug('PDF Converter: Document, id: '.$this->document->iId.', could not be converted to pdf.'); + return _kt("The document, id: {$this->document->iId}, could not be converted to pdf format. The following error occurred: \"{$res}\"."); } return true; @@ -169,11 +197,11 @@ class pdfConverter extends BaseProcessor // Get contents and send to converter $result = $this->xmlrpc->convertDocument($sourceFile, $targetFile, $this->ooHost, $this->ooPort); - if($result === false){ + if(is_string($result)){ $default->log->error('PDF Converter Plugin: Conversion to PDF Failed'); @unlink($sourceFile); @unlink($targetFile); - return false; + return $result; } $pdfDir = $default->pdfDirectory; @@ -196,7 +224,7 @@ class pdfConverter extends BaseProcessor $res = @copy($targetFile, $pdfFile); @unlink($sourceFile); @unlink($targetFile); - return $pdfFile; + return true; } } diff --git a/search2/indexing/lib/XmlRpcLucene.inc.php b/search2/indexing/lib/XmlRpcLucene.inc.php index 156c929..38fc01c 100755 --- a/search2/indexing/lib/XmlRpcLucene.inc.php +++ b/search2/indexing/lib/XmlRpcLucene.inc.php @@ -416,7 +416,7 @@ class XmlRpcLucene if($result->faultCode()) { $this->error($result, 'convertDocument'); - return false; + return $result->faultString(); } return php_xmlrpc_decode($result->value()) == 0; }