Setup Guide for Open-Source File Preview Tool kkFileView
Tool Introduction
kkFileView is an open-source file conversion and online preview tool built on Spring Boot and OpenOffice. It supports a wide range of formats including doc, docx, ppt, pptx, xls, xlsx, zip, rar, mp4, mp3, and various text/code files like txt, html, xml, java, properties, sql, js, md, json, conf, ini, vue, php, py, bat, and gitignore. The latest compiled version requires access to a paid group, but an older free version (2.2.1) is available from the official hidden URL, and you can also compile the source code yourself using Maven.
Environment Requirements
- Java Runtime Environment (JRE) 8 or later
- OpenOffice or LibreOffice (OpenOffice is used here)
- Compiled kkFileView package
- Chinese font package (to avoid garbled characters)
Installation Steps
1. Java Installation
# Download JDK 8u202 from Huawei Cloud mirror
wget https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz
# Extract to /usr/local
mkdir -p /usr/local && tar -xzf jdk-8u202-linux-x64.tar.gz -C /usr/local/
# Configure environment variables in /etc/profile
echo 'export JAVA_HOME=/usr/local/jdk1.8.0_202' >> /etc/profile
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib' >> /etc/profile
# Apply changes and verify installation
source /etc/profile && java -version
2. OpenOffice Installation
# Download Apache OpenOffice 4.1.15 Chinese version from SourceForge
wget https://sourceforge.net/projects/openofficeorg.mirror/files/4.1.15/binaries/zh-CN/Apache_OpenOffice_4.1.15_Linux_x86-64_install-rpm_zh-CN.tar.gz
# Extract the installation package
tar -xzf Apache_OpenOffice_4.1.15_Linux_x86-64_install-rpm_zh-CN.tar.gz
# Install all RPM packages in the RPMS directory
cd zh-CN/RPMS && rpm -ivh *.rpm
# Install desktop integration package
cd desktop-integration && rpm -ivh openoffice4.1.15-freedesktop-menus-4.1.15-9813.noarch.rpm
# Verify OpenOffice installation
which soffice
3. kkFileView Installation
# Obtain the compiled package (version 4.3.0 here, can be compiled from GitHub source)
# Extract to /usr/local
tar -xzf kkFileView-4.3.0.tar.gz -C /usr/local/
# Start kkFileView
cd /usr/local/kkFileView-4.3.0/bin && sh startup.sh
# Check if port 8012 is listening
netstat -nltp | grep 8012
4. Chinese Font Configuration
# Download Chinese font package
wget http://kkfileview.keking.cn/fonts.zip
# Extract and move to system font directory
unzip fonts.zip && mv zhFonts /usr/share/fonts/
# Set font permissions
chmod -R 755 /usr/share/fonts/zhFonts/*
# Refresh font cache
cd /usr/share/fonts/zhFonts/ && mkfontscale && mkfontdir && fc-cache && fc-cache -fv
source /etc/profile
References
- Apache OpenOffice Installation Guide: https://blog.csdn.net/carefree2005/article/details/131231530
- kkFileView Usage Reference: https://blog.csdn.net/qq_53930044/article/details/135600296