我正在尝试将word文档转换为文本,我使用下面的代码:
public function executeManoj() {
$filename='C:\xampp\htdocs\branch.com\web\greenwich-beer-and-jazz-application-form.doc';
$TXTfilename = $filename . ".txt";
$word = new COM("word.application") or die("Unable to instantiate Word object");
$word->Documents->Open($filename);
// the '2' parameter specifies saving in txt format
$word->Documents[1]->SaveAs($TXTfilename ,2);
$word->Documents[1]->Close(false);
$word->Quit();
$word->Release();
$word = NULL;
unset($word);
$content = file_get_contents($TXTfilename);
//unlink($TXTfilename);
exit;
}
但是导致错误说
“无法创建COM对象`word.application':语法无效”....
我在xammp中设置了“允许服务与桌面交互”。
我需要先安装任何软件吗?