kkFileView实现文件在线预览

官网:https://kkfileview.keking.cn/
官方文档:  https://kkfileview.keking.cn/zh-cn/docs/home.html

环境要求

Java: 1.8+
LibreOffice

1. 安装 LibreOffice7.1.4

下载 LibreOffice_7.1.4

` 如果安装过LIBREOFFICE,需要先卸载 [root@localhost src]# find / -name "libreoffice*" #检测是否有安装过,没有则跳过下一步 [root@localhost src]# yum remove libreoffice* #卸载原先的libreoffice软件

[root@localhost ~]# cd /usr/local/

上传文件到此目录

[root@localhost src]# tar zxvf LibreOffice_7.1.4_Linux_x86-64_rpm.tar.gz #解压 [root@localhost local]# cd LibreOffice_7.1.4.2_Linux_x86-64_rpm/ [root@localhost LibreOffice_7.1.4.2_Linux_x86-64_rpm]# ll total 16 -rwxr-xr-x 1 root root 10510 May 7 19:03 install drwxr-xr-x 2 root root 26 May 7 19:03 readmes drwxrwxr-x 2 root root 4096 May 7 19:03 RPMS

[root@localhost LibreOffice_7.1.4.2_Linux_x86-64_rpm]# cd RPMS/ [root@localhost RPMS]# yum localinstall *.rpm #安装本地安装rpm包

通过查询下面的内容可以找到安装目录 [root@localhost RPMS]# which libreoffice7.1 /usr/bin/libreoffice7.1 [root@localhost RPMS]# ll /usr/bin/libreoffice7.0 lrwxrwxrwx 1 root root 35 Dec 26 22:55 /usr/bin/libreoffice7.1 -> /opt/libreoffice7.1/program/soffice

添加路径

[root@localhost RPMS]# vim /etc/profile export PATH=$PATH/opt/libreoffice7.1/program/soffice [root@localhost RPMS]# source /etc/profile [root@localhost RPMS]# soffice --version

能显示版本号就ok, 如果报错:

/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libcairo.so.2: cannot open shared object file: No such file or directory 缺少libcairo.so.2依赖库 yum install ibus

至此, libreoffice 安装工作完成.


2. 部署 kkFileView

下载项目包 并解压

最新4.0版本

修改配置参数
解压后目录如下

[root@localhost kkFileView-4.0.0]# ll total 0 drwxr-xr-x 2 root root 107 Dec 26 22:46 bin drwxrwxrwx 2 root root 102 Dec 26 23:02 config drwxrwxrwx 2 root root 84 Dec 26 22:57 log

修改 application.properties 文件

vim application.properties

配置预览文件临时存储目录

配置libreoffice地址 /opt/libreoffice7.1/program

启动服务

``[root@localhost bin]# ./startup.sh Using KKFILEVIEW_BIN_FOLDER /opt/data/soft/kkFileView-4.0.0/bin Detected office component has been installed in /opt/libreoffice7.1 Starting kkFileView... Please execute ./showlog.sh to check log for more information You can get help in our official homesite: https://kkFileView.keking.cn If this project is helpful to you, please star it on https://gitee.com/kekingcn/file-online-preview/stargazers

查看启动日志

[root@localhost bin]# ./showlog.sh => Spring Boot :: (v2.4.2) QQ1 :: 613025121 => kkFileView :: (v4.0.0) QQ2 :: 484680571 => github :: https://github.com/kekingcn/kkFileView => gitee :: https://gitee.com/kekingcn/file-online-preview

2021-12-26 23:04:04.884 INFO 17219 --- [ main] org.eclipse.jetty.util.log : Logging initialized @3166ms to org.eclipse.jetty.util.log.Slf4jLog``

测试服务

打开服务web页面, localhost:8012/index

预览文件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章