使用php查找Ppt文件的页码


Find out page numbers of Ppt files with php

我想获取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":未知名称

这类问题是由以下因素造成的。

  1. PHP.ini设置
  2. 文件/文件夹权限
  3. 未在服务器中启用允许打开
  4. 允许的上载大小

我得到了答案,感谢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();