PHP COM PowerPoint另存为PDF和关闭演示文稿

I want to convert a PPT/PPTX to PDF using COM extension for PHP under Windows. I struggled a lot without any succes using ExportAsFixedFormat and I used instead SaveAs method(). The PDF does get generated but the script never finishes. Opening Task Manager I can see that the PowerPoint process is still running... I can't get it to close.

With Word everything works fine with this code:

$word->ActiveDocument->Close(false);
$word->Quit();
$word = null;
unset($word);

With PowerPoint I'm using this code with no luck:

$powerpnt = new COM('powerpoint.application') or die('Unable to load PowerPoint');
$powerpnt->Visible = true;

// Open an existing document
$doc = $powerpnt->Presentations->Open('powerpoint.pptx');
$doc->SaveAs('powerpoint.pdf', 32, 1);

$doc->Close();

$powerpnt->Quit();
$powerpnt = null;
unset($powerpnt);

I also tried, but still without working:

$powerpnt->Presentations[1]->Close();
$powerpnt->Presentations("powerpoint.pptx")->Close();
$powerpnt->ActivePresentation->Close(); // this generates an error

I would really appreciate some insight. Thank you

You must specify exact path so change : $doc = $powerpnt->Presentations->Open('powerpoint.pptx'); $doc->SaveAs('powerpoint.pdf', 32, 1);

TO: $doc = $powerpnt->Presentations->Open('D:\powerpoint.pptx'); $doc->SaveAs('D:\powerpoint.pdf', 32, 1);