1. Need to install Office on the app server
2. You may need to create a folder: Desktop
C:\Windows\SysWOW64\config\systemprofile\Desktop
3. You may need to set permissions in the component service, locate the "Microsoft Office ..." property, set the related permissions
4. You may need to set the login username and password for the Apache service
functionGetrtftext ($rtfFileName) { $result= ' '; if(!Is_file($rtfFileName)) { Throw NewErrorexception ("File not found.")); } $rtfFileName=Realpath($rtfFileName); //Connect to Word if(!class_exists(' COM ')) { Throw NewErrorexception (' COM extension is not enabled. ')); } $word=NewCOM ("Word.Application"); if(!$word) { Throw NewErrorexception (' Unable to instantiate Word COM object. '); } //Check the Word version. if($word->version < 12) { $word-Quit (); $word=NULL; Throw NewErrorexception (' The version of Word is too old. ')); } //$word->visible = 1; Try { //documents.open:http://msdn.microsoft.com/en-us/library/office/ff835182%28v=office.14%29.aspx//$word Visible=true; $word->documents->open ($rtfFileName,FALSE,TRUE); $result=$word->activedocument->content->Text; $word->activedocument->close (FALSE); //echo '. $test;}Catch(Exception $e) { $word-Quit (); $word=NULL; Throw $e; } Try { $word-Quit (); $word=NULL; } Catch(Exception $e) { Var_dump($e); } return $result;}
PHP uses COM to get Rich text content