phpdocx 安装使用(Linux,Windows)
这里着重介绍LINUX版安装
Linux 版
(一)、软件支持:
1. 下载phpdocx工具包(pro版base$299/公司$599/企业版$999) phpdocx-(公司/企业/trial-pro-6.0).tar
2. 下载java jdk,如有jdk忽略此步骤 jdk-8u111-linux-x64.tar.gz
3. 下载 Apache_OpenOffice 根据CPU型号下载对应版本 Apache_OpenOffice_3.2.0_Linux_x86-64_install-rpm_zh-CN.tar.gz
(二)、openOffice安装:
1.使用tar -xzvf OOo_3.2.0_LinuxIntel_install_wJRE_en-US.tar.gz解压缩后,会得到OOO320_m12_native_packed-1_en-US.9483
目录。
2.进入OOO320_m12_native_packed-1_en-US.9483目录: cd OOO320_m12_native_packed-1_en-US.9483
3.进入到RPMS目录: cd RPMS
4.执行 rpm –ivh *rpm(安装所有rpm文件)
5.进入到desktop-integration目录 cd desktop-integration
6.执行 rpm -ivh openoffice.org3.2-redhat-menus-3.2-9472.noarch.rpm
这时openOffice己经安装完成,默认会安装在/opt下
(三)、启动openOffice服务
1.进入opt目录:cd /opt
2.进入openoffice.org3目录: cd openoffice.org3
3.进入program目录
4.执行 soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &
5.完成启动
(四)、添加缺省库
updatedb #更新yum 数据库
#可能缺省下面的库
yum install giflib.x86_64
yum install libexif.x86_64
(五)、DOC转换PDF添加中文字体
#选择 C:\Windows\Fonts 字体文件
#上传到linux字体库
cd /usr/share/fonts
mkdir chinese
cd chinese #上传字体文件到当前目录
fc-cache -fv #更新字体缓存
#重启oppenoffice
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &
注意事项-版本支持(base暂不支持doc转PDF;需要公司/企业版支持{} ):
【
1.版本功能对比篇: http://www.phpdocx.com/features
2.测试代码-官方实例篇: http://www.phpdocx.com/documentation/introduction/pdf-conversion-plugin-installation-guide
3.**doc转pdf 关注debug调试模式篇: http://www.phpdocx.com/documentation/conversion-plugin/debugging-openoffice
】
WINDOWS版
一.安装
1. 下载phpdocx工具包(pro版,公司/企业版为收费版本) phpdocx-(公司/企业/trial-pro-6.0).tar
二.Code:
<php>
#导入类库
require_once dirname(dirname(__FILE__)).'/phpdocx/classes/CreateDocx.inc';
#加载模板
$docx = new CreateDocxFromTemplate('template_gudo.docx');
#例如,替换文本占位符文本换行符:
$text = 'A web browser (commonly referred to as a browser) is a software application for retrieving, presenting and traversing information resources on the World Wide Web.\n
An information resource is identified by a Uniform Resource Identifier (URI/URL) and may be a web page, image, video or other piece of content.';
$docx->replaceVariableByText(array('TEXT' => $text), array('parseLineBreaks' => true));
$docx->replaceVariableByText(array('company_name' => 'xx科技有限公司'), array('parseLineBreaks' => true));
$docx->replaceVariableByText(array('verstring_second' => '从2020年12月12日至2050年12月12日成熟xx股;'), array('parseLineBreaks' => true));
// $docx->addText($text);
$generate_file_name=time();
#替换模版生成文件
$docx->createDocx($generate_file_name);
//DOC转换PDF
#由于的COM功能的特殊行为,最好是写的始发地和目的地文件夹的绝对路径,用双斜杠
#此处\\单斜杠转义
#$dir_path ='D:\\\xampp\htdocs\phpdocx_demo\\';
#$dir_path ='//alidata/www/default/phpdocx_demo/';
$dir_path = dirname(__FILE__).'/';
echo $doc_path = $dir_path.$generate_file_name.'.docx';
echo '<br/>';
echo $pdf_path =$dir_path.$generate_file_name.'.pdf';
#DOC转换PDF文档
$docx->transformDocxUsingMSWord($doc_path, $pdf_path);
</php>
发表评论
要发表评论,您必须先登录。