php将ppt转jpg图片的具体步骤代码
作者:小妮浅浅 时间:2023-06-12 21:53:33
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);
?>
来源:https://www.py.cn/php/jiaocheng/31599.html
标签:php,ppt转jpg
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
阿里云ECS centos6.8下安装配置MySql5.7的教程
2024-01-14 23:47:13
使用SQL Server 2000索引视图提高性能
2009-01-13 13:47:00
![](https://img.aspxhome.com/file/UploadPic/20091/200911419338684.gif)
php将文件夹打包成zip文件的简单实现方法
2024-05-11 09:48:14
PHP实现的注册,登录及查询用户资料功能API接口示例
2024-04-30 08:50:18
MySQL查询语句过程和EXPLAIN语句基本概念及其优化
2024-01-18 07:44:36
![](https://img.aspxhome.com/file/2023/2/76442_0s.png)
Python中的文件和目录操作实现代码
2022-08-30 15:12:11
MySQL数据库线程缓冲池详解
2012-04-13 11:48:01
Oracle中执行动态SQL
2024-01-19 20:55:37
![](https://img.aspxhome.com/file/2023/7/66547_0s.jpg)
python之PySide2安装使用及QT Designer UI设计案例教程
2023-01-18 06:42:53
![](https://img.aspxhome.com/file/2023/7/101747_0s.png)
MySQL实现字符串的拼接,截取,替换,查找位置的操作
2024-01-13 13:17:22
在django模板中实现超链接配置
2023-03-03 12:22:44
Python双版本计算器详解
2021-03-27 13:22:24
perl常量、多维数组及变量的初始化的实例代码
2022-03-10 07:59:54
sql server实现递归查询的方法示例
2024-01-23 00:57:17
对python实时得到鼠标位置的示例讲解
2022-02-21 10:01:25
![](https://img.aspxhome.com/file/2023/0/85380_0s.jpg)
使用Python中tkinter库简单gui界面制作及打包成exe的操作方法(二)
2023-04-25 19:32:40
Python 异步之如何保护任务免于取消详解
2022-08-04 05:03:26
SqlServer 巧妙解决多条件组合查询
2023-07-01 14:15:00
如何利用pandas将Excel转为html格式
2023-12-14 19:04:49
![](https://img.aspxhome.com/file/2023/7/121047_0s.png)
Window10下python3.7 安装与卸载教程图解
2021-02-15 16:23:54
![](https://img.aspxhome.com/file/2023/5/105565_0s.jpg)