PHP处理Word转PDF代码示例
2015-08-21 16:56
721 查看
PHP处理Word转PDF代码示例:
<</FONT> ?php
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){
$osm = new COM("com.sun.star.ServiceManager")
or die ("Please be sure that OpenOffice.org
is installed.\n");
$args = array(MakePropertyValue("Hidden",true,$osm));
$oDesktop = $osm->createInstance("com.sun.star
.frame.Desktop");
$oWriterDoc = $oDesktop->loadComponentFromURL
($doc_url,"_blank", 0, $args);
$export_args = array(MakePropertyValue
("FilterName","writer_pdf_Export",$osm));
$oWriterDoc->storeToURL($output_url,$export_args);
$oWriterDoc->close(true);
}
$output_dir = "D:/LightTPD/htdocs/";
$doc_file = "D:/LightTPD/htdocs/2.doc";
$pdf_file = "2.pdf";
$output_file = $output_dir
. $pdf_file;
$doc_file = "file:///" .
$doc_file;
$output_file = "file:///" .
$output_file;
word2pdf($doc_file,$output_file);
?>
以上这段代码就是PHP处理Word转PDF的相关实现方法。
<</FONT> ?php
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){
$osm = new COM("com.sun.star.ServiceManager")
or die ("Please be sure that OpenOffice.org
is installed.\n");
$args = array(MakePropertyValue("Hidden",true,$osm));
$oDesktop = $osm->createInstance("com.sun.star
.frame.Desktop");
$oWriterDoc = $oDesktop->loadComponentFromURL
($doc_url,"_blank", 0, $args);
$export_args = array(MakePropertyValue
("FilterName","writer_pdf_Export",$osm));
$oWriterDoc->storeToURL($output_url,$export_args);
$oWriterDoc->close(true);
}
$output_dir = "D:/LightTPD/htdocs/";
$doc_file = "D:/LightTPD/htdocs/2.doc";
$pdf_file = "2.pdf";
$output_file = $output_dir
. $pdf_file;
$doc_file = "file:///" .
$doc_file;
$output_file = "file:///" .
$output_file;
word2pdf($doc_file,$output_file);
?>
以上这段代码就是PHP处理Word转PDF的相关实现方法。
相关文章推荐
- htpasswd建立和更新存储用户名、密码
- EditPlus行首行尾批量添加字符
- 关于php mysql长连接、连接池的一些探索
- ViewPager + FragmentPagerAdapter的使用
- php匹配字符串中大写字母的位置
- thinkphp 类库扩展
- 【6】Laravel5.1的migration数据库迁移
- php-fpm 启动参数及重要配置详解
- php大力力 [002节]mac php环境安装,mamp安装 ,phpMyAdmin启动
- ntp版本导致时间同步不成功问题
- think php orm大小写问题
- 详细解读PHP的Yii框架中登陆功能的实现
- [php] smarty模板引擎
- php大力力 [001节]2015-08-21.php在百度文库的几个基础教程新手上路日记 大力力php 大力同学 2015-08-21 15:28
- 【5】说说Laravel5的blade模板
- 动态改变leftpanel的宽度
- phpcms v9 企业黄页加入企业会员提示“请选择企业库类型!”
- win7下安装matplotlib+six+pysparsing
- poi 中获得行数 getLastRowNum() 和 getPhysicalNumberOfRows()
- yii基础应用目录结构