php将ppt转成图片查看

php安装com组件

1、如php版本>5.3.15,需要保证ext文件夹下有php_com_dotnet.dell 并在php.ini中加入。

extension=php_com_dotnet.dll

2、去除com.allow_dcom = true前面的‘;’号。

com.allow_dcom = true

实例

$powerpnt = new com("powerpoint.application") or die("unable to instantiate powerpoint");
$file='e:/app/other/qwe.pptx';
$presentation = $powerpnt->presentations->open(realpath($file), false, false, false) or die("unable to open presentation");
foreach($presentation->slides as $slide)
{
$slidename = "slide_" . $slide->slidenumber;
$uploadsfolder = 'iii';
$exportfolder = realpath($uploadsfolder);
$slide->export($exportfolder."//".$slidename.".jpg", "jpg", "600", "400");
}
$presentation->close(); 
$powerpnt->quit();
$powerpnt = null;

?>

内容扩展:

从shell脚本中,您可以使用unoconv,它是libreoffice的简单命令行包装器,可以使您转换为合理的质量。

对于可以直接从php(以及linux)调用的具有更高质量输出的解决方案,您可以使用专用文件转换api,例如zamzar。

提交ppt(或pptx)文件以转换为jpeg的代码如下(documentation中的更多信息):

/ build request
$endpoint = "https://api.zamzar.com/v1/jobs";
$apikey = "your_key";
$sourcefilepath = "/tmp/my.ppt"; // or pptx
$targetformat = "jpg";
$sourcefile = curl_file_create($sourcefilepath);
$postdata = array(
"source_file" => $sourcefile,
"target_format" => $targetformat
);
// send request
$ch = curl_init();
curl_setopt($ch, curlopt_url, $endpoint);
curl_setopt($ch, curlopt_customrequest, 'post');
curl_setopt($ch, curlopt_postfields, $postdata);
curl_setopt($ch, curlopt_safe_upload, false);
curl_setopt($ch, curlopt_returntransfer, true);
curl_setopt($ch, curlopt_userpwd, $apikey . ":");
$body = curl_exec($ch);
curl_close($ch);
// process response (with link to converted files)
$response = json_decode($body, true);
print_r($response);
?>

到此这篇关于php将ppt转jpg图片的具体步骤代码的文章就介绍到这了,更多相关php将ppt转jpg图片的方法内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!