php操作openoffice把文件转换成pdf
来源:互联网 发布:伴随矩阵 编辑:程序博客网 时间:2024/06/06 00:18
1.上官网, http://www.openoffice.org。下载openoffice4.1.2
2.设置权限
cmd 运行Dcomcnfg.exe->组件服务->计算机->我的电脑->DCOM配置->OpenOffice Service Manager
3.打开openoffice 在进程中查看打开此进程的用户是谁 然后设置此用户的访问权限为允许
2.设置权限
cmd 运行Dcomcnfg.exe->组件服务->计算机->我的电脑->DCOM配置->OpenOffice Service Manager
3.打开openoffice 在进程中查看打开此进程的用户是谁 然后设置此用户的访问权限为允许
然后将标识调整为交互式
4.在php环境下运行此代码
<?php/** * Author: 宇翔大魔王 * Date: 17-1-6 * Time: 下午2:25 * TOpdf */set_time_limit(0);function MakePropertyValue($name,$value,$osm){ $oStruct = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue"); $oStruct->Name = $name; $oStruct->Value = $value; return $oStruct;}function word2pdf($doc_url, $output_url){ //Invoke the OpenOffice.org service manager $osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.\n"); //Set the application to remain hidden to avoid flashing the document onscreen $args = array(MakePropertyValue("Hidden",true,$osm)); //Launch the desktop $top = $osm->createInstance("com.sun.star.frame.Desktop"); //Load the .doc file, and pass in the "Hidden" property from above $oWriterDoc = $top->loadComponentFromURL($doc_url,"_blank", 0, $args); //Set up the arguments for the PDF output $export_args = array(MakePropertyValue("FilterName","writer_pdf_Export",$osm)); //Write out the PDF $oWriterDoc->storeToURL($output_url,$export_args); $oWriterDoc->close(true);}$doc_file = "file:///D:/wamp/www/study/phpr/201701/11.doc";$output_file = 'file:///D:/wamp/www/study/phpr/201701/11.pdf';word2pdf($doc_file,$output_file);?>
注意: 易错点:1.php首先得开启com组件
php5.45之前在php.ini设置com.allow_dcom = true
php5.45之后extension=php_com_dotnet.dll
2.doc_file和output_file路径必须严格要求为
file:///D:/wamp/www/study/phpr/201701/11.pdf
0 0
- php操作openoffice把文件转换成pdf
- 用php把word文件转换成pdf文件
- 把PPT文件转换成PDF如何操作
- 利用 jodconverter 和openoffice 结合 把doc、ppt 等一系列文档转换成pdf
- 怎么把ppt转换成pdf文件
- 怎样才能把pdf文件转换成jpg
- 如何才能把word转换成pdf文件
- 利用OpenOffice将word转换成PDF
- 通过OpenOffice转换PDF
- 通过OpenOffice转换PDF
- OpenOffice文件转换的使用(php)
- 怎么把ppt文件转换成pdf文件在线转换
- openoffice实现office文件转换为pdf实现文件预览
- OpenOffice将MS docx转换成pdf文件偶数页眉不显示问题解决办法
- OpenOffice+JodConverter实现Office文件到PDF的转换
- 活用office工具把PDF文件转换成word文件
- 如何免费把pdf文件转换成txt文件
- OpenOffice 转换pdf->图片 代码
- kernel 中断分析五——irq_thread
- UISearchController搜索框偏移问题 - 芒果iOS开发
- Grafana3.1.0的使用
- Android 改变Viewpager的滚动速度
- HDU 1789 Doing Homework again(贪心)
- php操作openoffice把文件转换成pdf
- 2017年你不得不知的学习诀窍
- C++字符串转数字
- MacOS搭建Caffe
- JS新API标准 地理定位(navigator.geolocation)
- 扑克牌技巧_百度百科
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- 使用gradle打包多个变体(variant)
- Python 小程序 绘制 小蛇