我想获取ppt文件的页码。我的代码:
$filename = "aaa.ppt";
$word = new COM("Powerpoint.Application");
$word->PresentationDocument->Open($filename);
$wdStatisticPages = 2; // Value that corresponds to the Page count in the Statistics
echo $word->ActivePresentation->SlideParts->Count($wdStatisticPages);
$word->ActivePresentation->Close();
$word->Quit();
但它给出了错误:
致命错误:未捕获异常"com_exception",消息为"Unable"查找"PresentationDocument":未知名称
这类问题是由以下因素造成的。
- PHP.ini设置
- 文件/文件夹权限
- 未在服务器中启用允许打开
- 允许的上载大小
我得到了答案,感谢Suyog的努力。
$filename = "aaa.ppt";
$power = new COM("Powerpoint.Application");
$power->visible = True;
$power->Presentations->Open(realpath($filename));
echo $power->ActivePresentation->Slides->Count;
//$word->ActiveDocument->PrintOut();
$power->ActivePresentation->Close();
$power->Quit();