Universal tool for online document preview. Based on the Spring Boot framework and SPI pluggable mode, it can be quickly integrated into Spring Boot projects to achieve file online preview functionality.
Supported formats:
- Images: jpg、jpeg、png、gif
- Documents: doc、docx、pdf、xls、xlsx、csv
- Text: txt、json、htmL
- Video: mp4、avi
- CAD: dwg、dxf
components Name | Description |
---|---|
file-viewer-core |
Core package comprising file preview entry points and generic file handling logic.(txt、json、csv、htmL、pdf、jpg、jpeg、png、gif、mp4、avi) |
file-viewer-cad |
CAD format processing module (dwg、dxf) |
file-viewer-poi |
document format processing module (doc、docx、xls、xlsx) |
You can individually import each module according to your needs, or you can import all modules collectively by using the file-viewer-all
package.
Mode one:To import all dependencies
<dependency>
<groupId>io.github.weimin96</groupId>
<artifactId>file-viewer-all</artifactId>
<version>${lastVersion}</version>
</dependency>
Mode two:Separate introduction
core module(must)
<dependency>
<groupId>io.github.weimin96</groupId>
<artifactId>file-viewer-core</artifactId>
<version>${lastVersion}</version>
</dependency>
cad module
<dependency>
<groupId>io.github.weimin96</groupId>
<artifactId>file-viewer-cad</artifactId>
<version>${lastVersion}</version>
</dependency>
poi module
<dependency>
<groupId>io.github.weimin96</groupId>
<artifactId>file-viewer-poi</artifactId>
<version>${lastVersion}</version>
</dependency>
@GetMapping(value = "/preview")
public void preview(String path) {
File file = new File(path);
ViewerContext.preview(file);
}
All supported methods
1、Write HttpServletResponse
through MultipartFile
ViewerContext.preview(MultipartFile multipartFile);
2、Write HttpServletResponse
through InputStream
ViewerContext.preview(InputStream inputStream, String filenameOrExtension);
2、Write HttpServletResponse
through File
ViewerContext.preview(File file) ;