资源简介
在springboot+vue框架中使用element的上传控价实现附件的上传、下载,并结合openoffice实现附件的在线预览

代码片段和文件信息
package jpcd.soft.sys.knowledge.utils;
import org.springframework.beans.factory.annotation.Value;
import java.io.*;
import java.util.Date;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeManager;
public class Doc2PdfUtil {
//openOffice 安装路径
@Value(“${openOffice.LINUX_PATH}“)
public static String LINUX_PATH;
@Value(“${openOffice.WINDOWS_PATH}“)
public static String WINDOWS_PATH=“C:/Program Files (x86)/OpenOffice 4“;
@Value(“${openOffice.MAC_PATH}“)
public static String MAC_PATH;
//openOffice 文件保存路径
public static String LINUX_FILE_PATH=“/home/openOfficeToPdfPath“;
public static String WINDOWS_FILE_PATH=“e:/openOfficeToPdfPath“;
public static OfficeManager officeManager;
/**
* 使Office2003-2007全部格式的文档(.doc|.docx|.xls|.xlsx|.ppt|.pptx) 转化为pdf文件
*
* @param inputFilePath
* 源文件路径,如:“e:/test.docx“
* @param outputFilePath
* 目标文件路径,如:“e:/test_docx.pdf“
* @return
*/
public boolean openOfficeToHTML(String inputFilePath String outputFilePath) {
return office2Html(inputFilePath outputFilePath);
}
/**
* 根据操作系统的名称,获取OpenOffice.org 3的安装目录
* 如我的OpenOffice.org 3安装在:C:/Program Files (x86)/OpenOffice.org 3
*
* @return OpenOffice.org 3的安装目录
*/
public static String getOfficeHome() {
String osName = System.getProperty(“os.name“);
System.out.println(“操作系统名称:“+osName);
if (Pattern.matches(“Linux.*“ osName)) {
return LINUX_PATH;
} else if (Pattern.matches(“Windows.*“ osName)) {
return WINDOWS_PATH;
} else if (Pattern.matches(“Mac.*“ osName)) {
return MAC_PATH;
}
return null;
}
/**
* 根据操作系统的名称 获取文件保存路径
*/
public static String getFilePath() {
String osName = System.getProperty(“os.name“);
System.out.println(“操作系统名称:“+osName);
if (Pattern.matches(“Linux.*“ osName)) {
return LINUX_FILE_PATH;
} else if (Pattern.matches(“Windows.*“ osName)) {
return WINDOWS_FILE_PATH;
}
return null;
}
/**
* 连接OpenOffice.org 并且启动OpenOffice.org
*
* @return
*/
public OfficeManager getOfficeManager() {
DefaultOfficeManagerConfiguration config = new DefaultOfficeManagerConfiguration();
// 获取OpenOffice.org 3的安装目录
String officeHome = getOfficeHome();
config.setOfficeHome(officeHome);
// 启动OpenOffice的服务
System.out.println(“启动OpenOffice的服务“);
OfficeManager officeManager = config.buildOfficeManager();
officeManager.start();
return officeManager;
}
/**
* 转换文件
*
* @param inpu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6222 2019-01-14 20:25 springboot+element+vue之附件管理及在线预览\auve前台js相关方法.txt
文件 9844 2019-01-12 17:19 springboot+element+vue之附件管理及在线预览\Doc2PdfUtil.java
文件 6153 2019-01-14 20:23 springboot+element+vue之附件管理及在线预览\附件上传、下载及删除接口方法.txt
目录 0 2019-01-14 20:26 springboot+element+vue之附件管理及在线预览
----------- --------- ---------- ----- ----
22219 4
- 上一篇:DB62 90度弯角母座
- 下一篇:MSP430F149 read SD card
相关资源
- vue+elmentui+ueditor +KityFormula数学公式 编
- Vue核心技术 Vue+Vue-Router+Vuex+SSR实战精
- SystemVue介绍.docx
- 前端Vue+Node+MongoDB高级全栈开发
- vue实现导出Excel的两个js文件-Blob+Exp
- Blob.js+Export2Excel.js
- 关于Vue组件库开发详析
- reportdesign基于lodop的vue简单打印设计工
- SpringBoot +vue 框架项目.zip
- springboot+vue.js搭建图书管理系统开源项
- springboot+mybatis后台vue.js实现前端的音
- 基于vue20构建的在线电影网film
- vuekanban一个基于vue的可拖放kanbanboar
- vue26elementUI汽车管理系统demo
- 基于vue实现一个社交网站开发
- Vue25仿去哪儿网
- 一个以vuejs为前端框架的问卷调查平台
- vue高仿知乎日报单页面应用技术栈v
- 基于vue20的微商城
- SystemVue仿真指导
- SysemVue Examples (SystemVue )
- 银行Logo银行列表银行名称银行编码
- Vue2.x 全家桶+Vant 搭建大型单页面电商
- 用vue写的公众号
- vue.js 快速入门(申思维) 配套源代码
- 2018尚硅谷10月最新全套打包视频网盘
- SpringBoot整合Vue最佳实践
- Vue2电影站源码
- 基于Vue的仓库管理前端工程
- Systemvue系统仿真技术应用讲义.pdf
评论
共有 条评论