一、准备工作(下载软件等等)

1、openoffice官网下载地址 http://www.openoffice.org/zh-cn/download/    下载你需要的版本,windows或者linux等等

2、除了openoffice以外我们还需要用到pdf2htmlEX这个软件;下载地址https://github.com/coolwanglu/pdf2htmlEX/;https://github.com/coolwanglu/pdf2htmlEX/wiki/Building 这里有具体的安装步骤说明,作者是以Fedora为示例,CentOS也类似,其中大部分依赖项可以通过yum安装,不必一一用源码安装      ;pdf2htmlEX需要依赖2.0。通过pdf2htmlEX作者放出的分支,下载fontforge:https://github.com/coolwanglu/fontforge/tree/pdf2htmlEX,查看INSTALL-Git.md文件,其中的fontforge需要手动单独安装,因为目前的yum源中的fontforge版本是低于2.0的,按照说明依次执行:(windows的可以忽略此步骤,直接去下载一个windows版本的,我分享的下载链接里也会有pdf2htmlEX windows版本的)

二、安装

1、安装openoffice

将下载好的tar包解压出来,进入到RPMS目录,然后会看到很多rpm的包,直接全部安装

 rpm -ivh *.rpm

安装完成后会生成一个desktop-integration文件夹,进入desktop-integration文件夹

[zzq@weekend110 RPMS]$ cd desktop-integration/
查看有以下几个版本
[zzq@weekend110 desktop-integration]$ ll
总用量 2004
-rw-rw-r--. 1 zzq zzq 469674 9月  26 2016 openoffice4.1.3-freedesktop-menus-4.1.3-9783.noarch.rpm
-rw-rw-r--. 1 zzq zzq 490143 9月  26 2016 openoffice4.1.3-mandriva-menus-4.1.3-9783.noarch.rpm
-rw-rw-r--. 1 zzq zzq 541506 9月  26 2016 openoffice4.1.3-redhat-menus-4.1.3-9783.noarch.rpm
-rw-rw-r--. 1 zzq zzq 544148 9月  26 2016 openoffice4.1.3-suse-menus-4.1.3-9783.noarch.rpm

我的是centos接近于Redhat所以我安装的是Redhat版本

[zzq@weekend110 desktop-integration]$ sudo rpm -ivh openoffice4.1.3-redhat-menus-4.1.3-9783.noarch.rpm
[sudo] password for zzq:
准备中...                          ################################# [100%]file /usr/bin/soffice from install of openoffice4.1.3-redhat-menus-4.1.3-9783.noarch conflicts with file from package libreoffice-core-1:5.0.6.2-3.el7.x86_64

下面就是启动openOffice

[zzq@weekend110 desktop-integration]$ soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &
[1] 23269
[zzq@weekend110 desktop-integration]$ Warning: -headless is deprecated.  Use --headless instead.
Warning: -accept=socket,host=127.0.0.1,port=8100;urp; is deprecated.  Use --accept=socket,host=127.0.0.1,port=8100;urp; instead.
Warning: -nofirststartwizard is deprecated.  Use --nofirststartwizard instead.
查看进程
[zzq@weekend110 desktop-integration]$
[zzq@weekend110 ~]$ ps -ef | grep 8100
zzq       23286      1  0 11:22 ?        00:00:00 /usr/lib64/libreoffice/program/soffice.bin -headless -accept=socket,host=127.0.0.1,port=8100;urp; -nofirststartwizard
zzq       27004  25312  0 11:31 pts/2    00:00:00 grep --color=auto 8100

有进程则表示openoffice已经启动成功了(windows上检测端口的命令为netstat -ano | findstr "8100")。

2、安装pdf2htmlEX

从githut下载压缩包解压,必须要先安装fontforge-pdf2htmlEX

[zzq@weekend110 software]$ unzip -o -d ~/app/  pdf2htmlEX-master.zip
[zzq@weekend110 software]$ unzip -o -d ~/app/ fontforge-pdf2htmlEX.zip
[zzq@weekend110 software]$ cd ~/app
[zzq@weekend110 app]$ ll
总用量 12
drwxr-xr-x. 11 zzq zzq  204 4月  13 14:53 apache-activemq-5.11.1
drwxr-xr-x.  9 zzq zzq  160 3月   9 13:50 apache-tomcat-7.0.76
drwxr-xr-x. 10 zzq zzq  258 4月  13 16:57 FastDFS
drwxrwxr-x. 33 zzq zzq 4096 3月  22 2014 fontforge-pdf2htmlEX
drwxr-xr-x.  8 zzq zzq  233 4月  11 2015 jdk1.7.0_80
drwxr-xr-x. 10 zzq zzq  187 4月  12 01:19 jprofiler10.0.1
drwxrwxr-x.  4 zzq zzq  124 2月  27 2015 libfastcommon-master
drwxr-xr-x.  8 zzq zzq  113 7月  10 2015 nexus-2.11.4-01
drwxrwxr-x.  8 zzq zzq 4096 7月  18 11:54 pdf2htmlEX-master
-rwxrw-r--.  1 zzq zzq   90 4月   9 18:24 run.sh
drwxr-xr-x.  3 zzq zzq   37 7月  10 2015 sonatype-work
drwxrwxr-x.  5 zzq zzq   49 9月  26 2016 zh-CN

进入到fontforge-pdf2htmlEX依次执行

./autogen.sh
./configure
make
make install

注意安装fontforge相关依赖

sudo yum install libtool* -y不安装就会报错Preparing build ... ERROR: libtoolize failed
安装 fontforge-pdf2htmlEX
[zzq@weekend110 fontforge-pdf2htmlEX]$ sudo ./autogen.sh
Preparing the fontforge build system...please waitFound GNU Autoconf version 2.69
Found GNU Automake version 1.13.4
Found GNU Libtool version 2.4.2Automatically preparing build ... doneThe fontforge build system is now prepared.  To build here, run:./configuremake
[zzq@weekend110 fontforge-pdf2htmlEX]$ ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
看到有报错,因为还缺少一些东西 glib和gio 安装他们 再执行上一步
configure: error: Package requirements (glib-2.0 >= 2.6 gio-2.0) were not met:No package 'glib-2.0' found
No package 'gio-2.0' foundConsider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.Alternatively, you may set the environment variables GLIB_CFLAGS
and GLIB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
[zzq@weekend110 fontforge-pdf2htmlEX]$ make
make: *** 没有指明目标并且找不到 makefile。 停止。
[zzq@weekend110 fontforge-pdf2htmlEX]$ sudo yum install glib* gio* freetype*  pango* -y[zzq@weekend110 fontforge-pdf2htmlEX]$make && make install

执行到这里fontforge-pdf2htmlEX就安装成功了

2、安装pdf2htmlEX

[zzq@weekend110 pdf2htmlEX-master]$ cmake .
-- checking for module 'poppler>=0.25.0'
--   package 'poppler>=0.25.0' not found
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:279 (message):A required package was not found
Call Stack (most recent call first):/usr/share/cmake/Modules/FindPkgConfig.cmake:333 (_pkg_check_modules_internal)CMakeLists.txt:22 (pkg_check_modules)-- checking for module 'cairo>=1.10.0'
--   package 'cairo>=1.10.0' not found
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:279 (message):A required package was not found
Call Stack (most recent call first):/usr/share/cmake/Modules/FindPkgConfig.cmake:333 (_pkg_check_modules_internal)CMakeLists.txt:28 (pkg_check_modules)Trying to locate cairo-svg...
CMake Error at CMakeLists.txt:47 (message):Error: no SVG support found in Cairo-- Configuring incomplete, errors occurred!
See also "/home/zzq/app/pdf2htmlEX-master/CMakeFiles/CMakeOutput.log".
[zzq@weekend110 pdf2htmlEX-master]$ 此处报错,需要导入环境再执行
[root@weekend110 pdf2htmlEX-master]# yum install poppler* -y
[root@weekend110 pdf2htmlEX-master]#  export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

再次执行cmake . 最后一步

[root@weekend110 pdf2htmlEX-master]# make && make install

安装完毕然后我们用命令查看一下版本

[root@weekend110 pdf2htmlEX-master]# pdf2htmlEX -v
pdf2htmlEX: error while loading shared libraries: libfontforge.so.2: cannot open shared object file: No such file or directory
查看pdf2htmlEX版本。但执行转换操作时还会报错:因此,需要导入lib库路径,很简单,vi /etc/profile,在最后加上
[root@weekend110 pdf2htmlEX-master]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
[root@weekend110 pdf2htmlEX-master]# pdf2htmlEX -v
pdf2htmlEX version 0.14.6
Copyright 2012-2015 Lu Wang <coolwanglu@gmail.com> and other contributors
Libraries: poppler 0.26.5libfontforge 20170718cairo 1.14.2
Default data-dir: /usr/local/share/pdf2htmlEX
Supported image format: png jpg svg

安装成功后打个jar的运行结果

这是我在windows上的运行结果:

这是主函数:Test.java

package util;import java.io.File;public class Test {public static void main(String[] args){//String a[] = {"C:\\Users\\sevnce\\Desktop\\exceljs\\test.xlsx","e:\\office\\1.pdf","pdfhtm.html"};System.out.println("args length : "+args.length);//3个参数 第一个是需要转换的excel文件  第二个是转换的pdf路径和名称 第三个是转换的html文件名称office2pdf2html(args);//office2html();}public static void office2pdf2html(String [] args) {String sourceFile = args[0];//"C:\\Users\\sevnce\\Desktop\\exceljs\\test.xlsx";String destFile = args[1];//"e:\\office\\1.pdf";String htmlFile = args[2];//"pdfhtmlc.html";// office文件转pdfint result = Office2PDFUtil.office2PDF(sourceFile, destFile);if(result == 0) {System.out.println("office转PDF成功");// pdf转htmlif(Pdf2htmlEXUtil.pdf2html(destFile, htmlFile)) {System.out.println("pdf转html成功");}else System.out.println("pdf转html失败");} else if(result == -1) {System.out.println("找不到源文件, 或url.properties配置错误");} else {System.out.println("office转PDF失败");}//System.out.println(ClearHtml2Div.clearFormat(htmlStr, docImgPath));}public static void office2html() {System.out.println(Doc2HtmlUtil.office2HtmlString(new File("C:\\Users\\sevnce\\Desktop\\exceljs\\test.xlsx"), "e:/office/test"));}
}

分享下资料和代码的下载地址:http://download.csdn.net/detail/baidu_19473529/9903553

fontforge-pdf2htmlEX.zip是linux安装pdf2htmlEX的依赖;jodconverter-2.2.2.zip是所需lib包;pdf2htmlEX-master.zip是Linux的pdf2htmlEX;pdf2htmlEX-win32-0.14.6-upx-with-poppler-data.zip是windows的pdf2htmlEX程序;previewOnline.zip是源代码里面都封装好了excel、doc等office文档转pdf和html的方法。

/**********************************安装时遇到的一些问题************************************/

1、/opt/openoffice4/program/soffice.bin: error while loading shared libraries: libXext.so.6: cannot open shared object file: No such file or directory

找不到libXext.so.6文件,去系统里面的/usr/lib64 或者 /usr/lib 查看有没有这个文件,如果有就copy到/opt/openoffice4/program/目录里面,

赋予chmod 777  libXext.so.6 。如果没有那么要安装该包。

由于我的系统是64位,那么输入yum install libXext.x86_64 ,如果是32位系统输入:yum install libXext.i686  。安装完成后去那两个目录找libXext.so.6复制到

/opt/openoffice4/program/目录里面,赋予chmod 777  libXext.so.6 。

2、 /opt/openoffice4/program/soffice.bin: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory

找不到libfreetype.so.6文件,同上输入:yum install libfreetype.i686,安装完之后去那两个目录找libXext.so.6复制到/opt/openoffice4/program/目录里面,赋予权限。

3、报问题:no suitable windowing system found, exiting. (安装了图形化界面不会出现这个问题)
输入安装:yum groupinstall "X Window System" ,一路安装完之后重启系统,在启动openoffice服务看看。

最后总结下Linux安装pdf2htmlEX的坑比较多总是缺少一些依赖,不过仔细观察错误提示还是能很快解决的。希望能帮助大家上手openoffice

linux和windows安装openOffice将excel、doc文件转成pdf或html相关推荐

  1. 和doc的区别怎么转换手机_如何把doc文件转换成PDF格式?高手告诉你应该这么做...

    视频步骤: 知乎视频​www.zhihu.com 有时候老师让交的实验报告文件格式必须为PDF格式,因为PDF与不同的操作系统和软件版本具有很好的兼容性,所以大多数人都喜欢将Word转换成PDF.但有 ...

  2. react在线浏览doc_如何把doc文件转换成PDF格式?教你一招秒实现

    有时候老师让交的实验报告文件格式必须为PDF格式,因为PDF与不同的操作系统和软件版本具有很好的兼容性,所以大多数人都喜欢将Word转换成PDF.但有的同学的Word版本不能直接将doc文件转换成PD ...

  3. linux 实现doc文件转换成pdf文件

    1.下载两个包 [root@manage-host ~]# wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/6.3.0/rpm/x86_6 ...

  4. 如何将doc格式转换成pdf格式的文件

    随着信息化进程的加快,电子文档的使用越来越广泛.在日常工作和学习中,我们经常需要使用各种类型的文档,如WORD.PPT.EXCEL等.其中,doc格式是最常用的文档格式同子设备上,我们可能会遇到doc ...

  5. linux 安装redis2.8.3,Linux及Windows安装Redis(详细)

    标签:Linux及Windows安装Redis 1.Windows安装教程 1.1下载 https://github.com/MSOpenTech/redis/releases 进入github里下载 ...

  6. linux系统怎么安装office软件,如何在Linux系统中安装OpenOffice

    Linux系统比如说Ubuntu或Linux Mint中是主要的办公软件,有些版本的系统中集成了这款软件,但是有些系统没有.所以下面就来给大家介绍一下,如何在Linux系统中安装OpenOffice. ...

  7. linux服务器 双显卡,linux dd windows 安装_双显卡安装windows和linux_windows 安装linux

    广告 提供包含云服务器,云在内的50+款云计算产品.打造一站式的云产品试用服务,助力开发者和企业零门槛上云. 检查 virtio 驱动操作详情请参考 linux 系统检测 virtio 驱动. 安装 ...

  8. Java通过openOffice实现word,excel,ppt转成pdf实现在线预览

    Java通过openOffice实现word,excel,ppt转成pdf实现在线预览 一.OpenOffice 1.1 下载地址 1.2 JodConverter 1.3 新建实体类PDFDemo ...

  9. linux和windows文件共享软件,桌面应用|如何在 Linux 和 Windows 之间共享 Steam 的游戏文件...

    简介:这篇详细的指南将向你展示如何在 Linux 和 Windows 之间共享 Steam 的游戏文件以节省下载的总用时和下载的数据量.我们将展示给你它是怎样为我们节约了 83% 的数据下载量. 假如 ...

最新文章

  1. SMRT single molecular real time Sequencing
  2. STM32 HAL库详解 及 手动移植
  3. 面试之BI-SQL--table转换
  4. UVA - 10061 How many zero#39;s and how many digits ?
  5. [转]MySQL索引背后的数据结构及算法原理
  6. idea 15 license server
  7. 在excel工作表中c1单元格_Excel工作表中的11个逻辑函数应用技巧,中文解读,动图演示!...
  8. iptables基本概念详解
  9. HDU 5820 Lights(扫描线+zkw线段树)
  10. 将图片背景处理为透明的方法步骤
  11. WPS Office政府机关单位专用版[安卓+Windows]
  12. 树莓派运用阿里云API实现语音识别
  13. 关于形而上学与形而下学之区别及关系
  14. DateTime转为特定时区时间
  15. 软件测试零基础入门好学吗?
  16. When you gather it, things would be counted. ​​​​
  17. 前端知识-JavaScript事件驱动特性
  18. 【阅读笔记】精益开发实践用看板管理大型项目
  19. Java数据类型问题
  20. 原生七彩影视APP源码 支持PC+WAP+APP三端

热门文章

  1. TurboMail邮件系统助力振华物流近十年
  2. 数学归纳法(1.2.1)
  3. 计算机知识竞赛赛制,【计算机·活动】校规校纪知识竞赛
  4. 一篇从零开始、步骤完整的网站搭建教程(全篇7000字、102张截图说明,力求每一个人都能看懂,附源码)
  5. android短视频技术,Android短视频开发都需要什么技术?
  6. 追逐自己的梦想----------辅助制作第二十课:完善自动技能打怪
  7. Marven:使用Maven构建Java项目
  8. L2-2 小字辈 (25 分)
  9. 服务器时间相差八小时问题解决
  10. PHP实现汉字笔画统计