pdf在线阅读
SpringBoot 使用LibreOffice 在线预览 doc,doxc,xls,xlsx,ppt,pptx 文件
linux环境源码安装unoconv
服务器环境为linux
linux版本非常多,每个版本之间的安装方式可能都会有所不同。这里就以centos 7做实例
1.切换到root用户:
su - root
2.执行unoconv安装码命令:
yum install unoconv –y
3.因为测试文件转换(文件上传自己处理)
使用rz或xftp
我这里rz上传的结构为 {
if (linuxPageDIsplsyFileUtil == null) {
linuxPageDIsplsyFileUtil = new LinuxPageDIsplsyFileUtil();
}
return linuxPageDIsplsyFileUtil;
}
/**
* 文档在线预览
*
* @param response
* @param fileStoragePath 文件存储路径 (前端获取文件存储路径返给后台)
* @param beforeConversion 文件名(必须带文件后缀名,这里指的就是文件全名称)
* @throws Exception
*/
public void conversionFile(HttpServletResponse response, String fileStoragePath, String beforeConversion) throws Exception {
//文件存储路径
//fileStoragePath ="/app/";
//转换前的文件名
//beforeConversion ="20191009133209lis_chgrpt.docx";
String fileNamePath = fileStoragePath + beforeConversion;
File file = new File(fileNamePath);
if (!file.exists()) {
log.info("库存中没有指定文件。。。。");
return;
}
//获取到文件名
String interceptFileName = beforeConversion.substring(0, beforeConversion.lastIndexOf("."));
//获取文件名的后缀
String extension = FilenameUtils.getExtension(file.getName());</