資源簡介
在springboot+vue框架中使用element的上傳控價(jià)實(shí)現(xiàn)附件的上傳、下載,并結(jié)合openoffice實(shí)現(xiàn)附件的在線預(yù)覽

代碼片段和文件信息
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)?轉(zhuǎn)化為pdf文件
?????*
?????*?@param?inputFilePath
?????*????????????源文件路徑,如:“e:/test.docx“
?????*?@param?outputFilePath
?????*????????????目標(biāo)文件路徑,如:“e:/test_docx.pdf“
?????*?@return
?????*/
????public?boolean?openOfficeToHTML(String?inputFilePath?String?outputFilePath)?{
????????return?office2Html(inputFilePath?outputFilePath);
????}
????/**
?????*?根據(jù)操作系統(tǒng)的名稱,獲取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(“操作系統(tǒng)名稱:“+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;
????}
????/**
?????*?根據(jù)操作系統(tǒng)的名稱?獲取文件保存路徑
?????*/
????public?static?String?getFilePath()?{
????????String?osName?=?System.getProperty(“os.name“);
????????System.out.println(“操作系統(tǒng)名稱:“+osName);
????????if?(Pattern.matches(“Linux.*“?osName))?{
????????????return?LINUX_FILE_PATH;
????????}?else?if?(Pattern.matches(“Windows.*“?osName))?{
????????????return?WINDOWS_FILE_PATH;
????????}
????????return?null;
????}
????/**
?????*?連接OpenOffice.org?并且啟動(dòng)OpenOffice.org
?????*
?????*?@return
?????*/
????public?OfficeManager?getOfficeManager()?{
????????DefaultOfficeManagerConfiguration?config?=?new?DefaultOfficeManagerConfiguration();
????????//?獲取OpenOffice.org?3的安裝目錄
????????String?officeHome?=?getOfficeHome();
????????config.setOfficeHome(officeHome);
????????//?啟動(dòng)OpenOffice的服務(wù)
????????System.out.println(“啟動(dòng)OpenOffice的服務(wù)“);
????????OfficeManager?officeManager?=?config.buildOfficeManager();
????????officeManager.start();
????????return?officeManager;
????}
????/**
?????*?轉(zhuǎn)換文件
?????*
?????*?@param?inpu
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????6222??2019-01-14?20:25??springboot+element+vue之附件管理及在線預(yù)覽\auve前臺(tái)js相關(guān)方法.txt
?????文件???????9844??2019-01-12?17:19??springboot+element+vue之附件管理及在線預(yù)覽\Doc2PdfUtil.java
?????文件???????6153??2019-01-14?20:23??springboot+element+vue之附件管理及在線預(yù)覽\附件上傳、下載及刪除接口方法.txt
?????目錄??????????0??2019-01-14?20:26??springboot+element+vue之附件管理及在線預(yù)覽
-----------?---------??----------?-----??----
????????????????22219????????????????????4
- 上一篇:DB62 90度彎角母座
- 下一篇:MSP430F149 read SD card
評論
共有 條評論