Home >Backend Development >PHP Tutorial >A detailed introduction to how php converts ppt to pictures and how php calls com components.

A detailed introduction to how php converts ppt to pictures and how php calls com components.

黄舟
黄舟Original
2017-06-18 13:40:132887browse

PHP calls the com component to convert ppt to picture.

Needs to be enabled in php.ini

extension=php_com_dotnet.dll
com.allow_dcom = true

The test code is as follows:

<?php
$powerpnt = new COM("powerpoint.application") or die("Unable to instantiate Powerpoint");
$file=&#39;1.ppt&#39;;
echo realpath($file);

$addr = $_SERVER[&#39;DOCUMENT_ROOT&#39;].&#39;/ppt/1.ppt&#39;;
echo $addr;
$presentation = $powerpnt->Presentations->Open($addr, false, false, false) or die("Unable to open presentation");


$presentation->Fonts->Replace(&#39;黑体&#39;,&#39;幼圆&#39;);
$presentation->Fonts->Replace(&#39;MS Gothic&#39;,&#39;幼圆&#39;);
$presentation->Fonts->Replace(&#39;方正粗倩简体&#39;,&#39;幼圆&#39;);
$presentation->Fonts->Replace(&#39;方正小标宋简体&#39;,&#39;幼圆&#39;);
$presentation->Fonts->Replace(&#39;Arial Black&#39;,&#39;幼圆&#39;);
$presentation->Fonts->Replace(&#39;华文中宋&#39;,&#39;幼圆&#39;);
$presentation->Fonts->Replace(&#39;Arial Unicode MS&#39;,&#39;幼圆&#39;);
$presentation->Fonts->Replace(&#39;方正细圆简体&#39;,&#39;幼圆&#39;);
$presentation->Fonts->Replace(&#39;Times New Roman&#39;,&#39;幼圆&#39;);


foreach($presentation->Fonts as $c)
{
	echo $c->name."<br />";
	//echo $c->Replace(&#39;&#39;,&#39;&#39;);
}


foreach($presentation->Slides as $slide)
{
$slideName = "Slide_" . $slide->SlideNumber;
$uploadsFolder = &#39;iii&#39;;
$exportFolder = realpath($uploadsFolder);
$slide->Export($exportFolder."//".$slideName.".jpg", "jpg", "1920", "1080");
}
$presentation->Close();
$powerpnt->Quit();
$powerpnt = null;
?>

Run on win7, no problem, but an error occurs when placed on 2008, there is oneexceptionCall unknown...

##Solution:

cmd -》dcomcnfg

The above is the detailed content of A detailed introduction to how php converts ppt to pictures and how php calls com components.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn