Online Document Preview with kkFileView: A Practical Guide

kkFileView is an open-source, Spring Boot-based document preview system designed for seamless online viewing of common file formats. With over 9.9k stars on GitHub, it supports a wide range of document types including DOC, DOCX, XLS, XLSX, PPT, PPTX, PDF, TXT, ZIP, RAR, as well as images, audio, and video files.

Docker Deployment

Deploying kkFileView via Docker is the fastest way to get started.

# If Docker Hub is accessible
docker pull keking/kkfileview:4.1.0

# If Docker Hub is restricted, load from local archive
wget https://kkview.cn/resource/kkFileView-4.1.0-docker.tar
docker load -i kkFileView-4.1.0-docker.tar

Run the container:

docker run -it -p 8012:8012 keking/kkfileview:4.1.0

Access the interface at http://127.0.0.1:8012 in your browser.

Integrating with You're Application

To preview a document from your own system, invoke the preview endpoint via a browser redirect. The service expects a Base64-encoded URL of the target file.

<script src="https://cdn.jsdelivr.net/npm/js-base64@3.6.0/base64.min.js"></script>

<script>
  const fileUrl = "https://example.com/documents/report.pdf";
  const encodedUrl = Base64.encode(fileUrl);
  window.open(`http://127.0.0.1:8012/onlinePreview?url=${encodeURIComponent(encodedUrl)}`);
</script>

Local Development on macOS

Clone the repository:

git clone git@github.com:kekingcn/kkFileView.git

kkFileView requires Java 1.8+ and a LibreOffice installasion. On macOS, LibreOffice is not bundled—download and install it manually from libreoffice.org.

Open the project in IntelliJ IDEA, navigate to the Server module, and execute ServerMain. The application starts two independent LibreOffice instances, each bound to a unique port for document conversion.

To build platform-specific packages, run:

mvn clean package

The build output will include binaries for Windows and Linux based on your Maven profile configuraton.

Linux Server Installation

Extract the Linux deployment package:

tar -zxvf kkFileView-4.4.0-SNAPSHOT.tar.gz
cd bin
./startup.sh

On first launch, the system automatically installs LibreOffice 7.5. Alternatively, install it manually:

cd /home
tar -zxvf LibreOffice_7.5.3.2_Linux_x86-64_rpm.tar.gz
cd LibreOffice_7.5.3.2_Linux_x86-64_rpm/RPMS/
yum -y localinstall *.rpm

Verify the installation:

libreoffice7.5 --version

Font Configuration

For proper text rendering, install supplemental fonts:

wget http://kkfileview.keking.cn/fonts.zip
sudo mkdir -p /usr/share/fonts/kkfileview
sudo unzip fonts.zip -d /usr/share/fonts/kkfileview/
sudo mkfontscale
sudo mkfontdir
sudo fc-cache -fv

Architecture Notes

kkFileView operates as a document transcoder—converting office files into HTML, images, or PDFs for browser rendering. For example, PPT slides are rendered as image sequences. All conversions occur locally on a single node, meaning scalability requires external orchestration. There is no built-in clustering or distributed storage.

While suitable for small to medium deployments, large-scale applications may need to supplement with object storage and load-balanced conversion workers.

Tags: SpringBoot libreoffice docker document-preview kkFileView

Posted on Mon, 07 Sep 2026 16:12:15 +0000 by petebolduc