最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

php如何实现openoffice转pdf

来源:动视网 责编:小采 时间:2020-11-02 18:26:19
文档

php如何实现openoffice转pdf

php如何实现openoffice转pdf:php openoffice转pdf的方法:首先下载openoffice4.1.2;然后将用户的访问权限为允许,并将标识调整为交互式;最后在php环境下运行代码为function MakePropertyValue(){}即可。推荐:《PHP视频教程》 php操作openoffice把文件转
推荐度:
导读php如何实现openoffice转pdf:php openoffice转pdf的方法:首先下载openoffice4.1.2;然后将用户的访问权限为允许,并将标识调整为交互式;最后在php环境下运行代码为function MakePropertyValue(){}即可。推荐:《PHP视频教程》 php操作openoffice把文件转


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.
");
 //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

php如何实现openoffice转pdf:php openoffice转pdf的方法:首先下载openoffice4.1.2;然后将用户的访问权限为允许,并将标识调整为交互式;最后在php环境下运行代码为function MakePropertyValue(){}即可。推荐:《PHP视频教程》 php操作openoffice把文件转
推荐度:
标签: PDF 转pdf 转换pdf
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top