您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php如何实现openoffice转pdf

2024/10/14 11:10:58发布38次查看
php openoffice转pdf的方法:首先下载“openoffice4.1.2”;然后将用户的访问权限为“允许”,并将标识调整为交互式;最后在php环境下运行代码为“function makepropertyvalue(){}”即可。
推荐:《php视频教程》 
php操作openoffice把文件转换成pdf
  1.上官网, http://www.openoffice.org。下载openoffice4.1.2
‍  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
以上就是php如何实现openoffice转pdf的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product