title: PHP COM PowerPoint save as PDF and close presentation
body: <p>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.</p>
  
  <p>With Word everything works fine with this code:</p>
  
  <pre><code>$word-&gt;ActiveDocument-&gt;Close(false);
  $word-&gt;Quit();
  $word = null;
  unset($word);
  </code></pre>
  
  <p>With PowerPoint I'm using this code with no luck:</p>
  
  <pre><code>$powerpnt = new COM('powerpoint.application') or die('Unable to load PowerPoint');
  $powerpnt-&gt;Visible = true;
  
  // Open an existing document
  $doc = $powerpnt-&gt;Presentations-&gt;Open('powerpoint.pptx');
  $doc-&gt;SaveAs('powerpoint.pdf', 32, 1);
  
  $doc-&gt;Close();
  
  $powerpnt-&gt;Quit();
  $powerpnt = null;
  unset($powerpnt);
  </code></pre>
  
  <p>I also tried, but still without working:</p>
  
  <pre><code>$powerpnt-&gt;Presentations[1]-&gt;Close();
  $powerpnt-&gt;Presentations("powerpoint.pptx")-&gt;Close();
  $powerpnt-&gt;ActivePresentation-&gt;Close(); // this generates an error
  </code></pre>
  
  <p>I would really appreciate some insight. Thank you</p>