This issue recommends kkFileView, an online document preview project built using spring boot.
kkFileView is a solution that uses spring boot to create online document preview projects. Support doc, docx, ppt, pptx, xls, xlsx, zip, rar, mp4, mp3 and many class texts such as txt, html, xml, java, properties, sql, js, md, json, conf, ini, vue, php, py, bat, gitignore and other files online preview.
Project characteristics
- Support word, excel, ppt, pdf and other office documents
- Support the TXT, Java, PHP, py, md, js, CSS, etc. All plain text
- Support zip,rar,jar,tar,gzip and other compression packages
- jpg, jpeg, png, gif and other image preview (flip, zoom, mirror)
- Support mp3, mp4, flv and other multimedia file preview
- Using spring boot development, the preview service setup deployment is very easy
- rest interfaces provide services, cross-platform features (java,php,python,go,php,….) Both are supported, and application access is simple and convenient
- Supports multiple preview sources, such as common http/https file download url, http/https file download stream url, and ftp download url
- The zip and tar.gz distribution packages provide one-click startup scripts and various configuration items for easy deployment
- Docker image distribution package for easy deployment in container environment
- Abstract preview service interface, very easy to add other types of file preview support
Deployment guide
1. environmental requirement
- Java: 1.8+
- OpenOffice or LiberOffice (built-in for Windows, automatically downloaded and installed for CentOS or Ubuntu, self-installed for MacOS)
2. Deploy and run
2.1 Running on a physical or virtual machine:
- Download the latest release from the Code Cloud distribution
- Decompress the kkFileView-x.x.x file (.zip for Windows and.tar.gz for Linux/MacOS).
- Open the bin directory of the decompressed folder and run the startup script (in Windows, run startup.bat as administrator, Linu x run startup.sh as root).
- You can access port 8012 http://127.0.0.1:8012 in your browser to see the home page of the project demonstration
2.2 Docker container environment environment run:
- Pull image
docker pull keking/kkfileview
- operation
docker run -it -p 8012:8012 keking/kkfileview
The browser accesses container port 8012
http://xxx.xxx.xxx.xxx:8012 can see demonstration project home page.
3.Use in the project
When you need to preview the file in your project, just call the browser to open the preview interface of the project, and pass in the url of the file that needs to be preview, as shown in the following example:
- 3. X. x version
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/js-base64@3.6.0/base64.min.js"></script>
var url = 'http://127.0.0.1:8080/file/test.txt'; //The access address to preview the file
window.open('http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(Base64.encode(previewUrl)));
- 2x. x and later versions
var url = 'http://127.0.0.1:8080/file/test.txt'; //The access address to preview the file
window.open('http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(previewUrl));
Preview display
- Text preview
All types of text document preview are supported. Too many types of text documents cannot be enumerated. The following types are enabled by default txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd,The text preview looks like this:
- word Document Preview
Support doc, docx document preview, word preview has two modes: one is to convert each page of word to picture preview, the other is to convert the entire word document to pdf, and then preview pdf.
Image preview mode preview effect is as follows:
pdf preview mode preview effect is as follows:
- Compressed file preview
Support zip,rar,jar,tar,gzip and other compressed packages, preview effect is as follows:
Click the file name in the compressed package to preview the file directly. The preview effect is as follows:
- CAD document preview
CAD dwg document preview is supported, and there are two preview modes, just like word documents.
Image preview mode preview effect is as follows:
pdf preview mode preview effect is as follows

You can read more on your own.