web项目使用OpenOffice实现前端在线预览office、pdf等文档源码
web项目使用OpenOffice实现前端在线预览office文档源码,同步博文讲解使用,手把手教学:https://blog.csdn.net/ITBigGod
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7234 2018-05-13 14:23 Test_Web.classpath
文件 1339 2018-05-13 15:04 Test_Web.project
....... 522 2017-11-19 12:48 Test_Web.settings.jsdtscope
....... 364 2017-11-19 12:48 Test_Web.settingsorg.eclipse.jdt.core.prefs
文件 501 2018-05-13 15:04 Test_Web.settingsorg.eclipse.wst.common.component
....... 414 2017-11-19 12:48 Test_Web.settingsorg.eclipse.wst.common.project.facet.core.xml
....... 49 2017-11-19 12:48 Test_Web.settingsorg.eclipse.wst.jsdt.ui.superType.container
....... 6 2017-11-19 12:48 Test_Web.settingsorg.eclipse.wst.jsdt.ui.superType.name
文件 8051 2018-05-13 15:12 Test_WebsrccomzoutDocConverter.java
....... 1544 2018-05-12 20:42 Test_WebWebRootdocumentUpload.jsp
文件 2866 2018-05-13 14:36 Test_WebWebRootdocumentView.jsp
文件 4353 2018-05-13 15:21 Test_WebWebRootdocUploadConvertAction.jsp
....... 412092 2018-05-12 20:35 Test_WebWebRootFlexPaperViewer.swf
....... 3501 2018-05-12 23:54 Test_WebWebRootindex.jsp
....... 10540 2018-05-12 20:35 Test_WebWebRootjsflexpaper_flash.js
....... 11519 2018-05-12 20:35 Test_WebWebRootjsflexpaper_flash_debug.js
....... 91342 2018-05-12 20:35 Test_WebWebRootjsjquery.js
....... 10220 2018-05-12 20:35 Test_WebWebRootjsswfobject.js
....... 39 2017-11-19 12:48 Test_WebWebRootmeta-INFMANIFEST.MF
文件 5821 2018-05-13 15:12 Test_WebWebRootWEB-INFclassescomzoutDocConverter.class
....... 55147 2018-05-11 15:33 Test_WebWebRootWEB-INFlibactivation.jar
....... 1336376 2018-05-11 15:33 Test_WebWebRootWEB-INFlibalipay-sdk-java20160712120059.jar
....... 4467 2018-05-11 15:33 Test_WebWebRootWEB-INFlibaopalliance-1.0.jar
....... 1545023 2018-05-11 15:33 Test_WebWebRootWEB-INFlibaspectjweaver.jar
....... 242477 2018-05-11 15:33 Test_WebWebRootWEB-INFlibsh-1.3.0.jar
....... 322362 2018-05-11 15:33 Test_WebWebRootWEB-INFlibcglib-nodep-2.2.jar
....... 188671 2018-05-11 15:33 Test_WebWebRootWEB-INFlibcommons-beanutils-1.7.0.jar
....... 206035 2018-05-11 15:33 Test_WebWebRootWEB-INFlibcommons-beanutils-core-1.8.0.jar
....... 118726 2018-05-11 15:33 Test_WebWebRootWEB-INFlibcommons-beanutils.jar
....... 41123 2018-05-12 21:58 Test_WebWebRootWEB-INFlibcommons-cli-1.2.jar
............此处省略80个文件信息
package com.zout;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
public class DocConverter {
private static final int environment = 1;// 环境1:windows2:linux(涉及pdf2swf路径问题)
private String fileString;
private String outputPath = ““;// 输入路径,如果不设置就输出在默认位置(可不修改)
private String fileName;
private File pdfFile;
private File swfFile;
private File docFile;
public DocConverter(String fileString) {
ini(fileString);
}
/*
* 重新设置 file @param fileString
*/
public void setFile(String fileString) {
ini(fileString);
}
/*
* 初始化 @param fileString
*/
private void ini(String fileString) {
this.fileString = fileString;
fileName = fileString.substring(0 fileString.lastIndexOf(“.“));
docFile = new File(fileString);
pdfFile = new File(fileName + “.pdf“);
swfFile = new File(fileName + “.swf“);
}
/*
* 转为PDF @param file
*/
private void doc2pdf() throws Exception {
if (docFile.exists()) {
if (!pdfFile.exists()) {
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(docFile pdfFile);
// close the connection
connection.disconnect();
System.out.println(“****pdf转换成功,PDF输出:“ + pdfFile.getPath() + “****“);
} catch (java.net.ConnectException e) {
// ToDo Auto-generated catch block
e.printStackTrace();
System.out.println(“****swf转换异常,openoffice服务未启动!****“);
throw e;
} catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
e.printStackTrace();
System.out.println(“****swf转换器异常,读取转换文件失败****“);
throw e;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
} else {
System.out.println(“****已经转换为pdf,不需要再进行转化****“);
}
} else {
System.out.println(“****swf转换器异常,需要转换的文档不存在,无法转换***
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7234 2018-05-13 14:23 Test_Web.classpath
文件 1339 2018-05-13 15:04 Test_Web.project
....... 522 2017-11-19 12:48 Test_Web.settings.jsdtscope
....... 364 2017-11-19 12:48 Test_Web.settingsorg.eclipse.jdt.core.prefs
文件 501 2018-05-13 15:04 Test_Web.settingsorg.eclipse.wst.common.component
....... 414 2017-11-19 12:48 Test_Web.settingsorg.eclipse.wst.common.project.facet.core.xm
....... 49 2017-11-19 12:48 Test_Web.settingsorg.eclipse.wst.jsdt.ui.superType.container
....... 6 2017-11-19 12:48 Test_Web.settingsorg.eclipse.wst.jsdt.ui.superType.name
文件 8051 2018-05-13 15:12 Test_WebsrccomzoutDocConverter.java
....... 1544 2018-05-12 20:42 Test_WebWebRootdocumentUpload.jsp
文件 2866 2018-05-13 14:36 Test_WebWebRootdocumentView.jsp
文件 4353 2018-05-13 15:21 Test_WebWebRootdocUploadConvertAction.jsp
....... 412092 2018-05-12 20:35 Test_WebWebRootFlexPaperViewer.swf
....... 3501 2018-05-12 23:54 Test_WebWebRootindex.jsp
....... 10540 2018-05-12 20:35 Test_WebWebRootjsflexpaper_flash.js
....... 11519 2018-05-12 20:35 Test_WebWebRootjsflexpaper_flash_debug.js
....... 91342 2018-05-12 20:35 Test_WebWebRootjsjquery.js
....... 10220 2018-05-12 20:35 Test_WebWebRootjsswfob
....... 39 2017-11-19 12:48 Test_WebWebRootme
文件 5821 2018-05-13 15:12 Test_WebWebRootWEB-INFclassescomzoutDocConverter.class
....... 55147 2018-05-11 15:33 Test_WebWebRootWEB-INFlibactivation.jar
....... 1336376 2018-05-11 15:33 Test_WebWebRootWEB-INFlibalipay-sdk-java20160712120059.jar
....... 4467 2018-05-11 15:33 Test_WebWebRootWEB-INFlibaopalliance-1.0.jar
....... 1545023 2018-05-11 15:33 Test_WebWebRootWEB-INFlibaspectjweaver.jar
....... 242477 2018-05-11 15:33 Test_WebWebRootWEB-INFlibsh-1.3.0.jar
....... 322362 2018-05-11 15:33 Test_WebWebRootWEB-INFlibcglib-nodep-2.2.jar
....... 188671 2018-05-11 15:33 Test_WebWebRootWEB-INFlibcommons-beanutils-1.7.0.jar
....... 206035 2018-05-11 15:33 Test_WebWebRootWEB-INFlibcommons-beanutils-core-1.8.0.jar
....... 118726 2018-05-11 15:33 Test_WebWebRootWEB-INFlibcommons-beanutils.jar
....... 41123 2018-05-12 21:58 Test_WebWebRootWEB-INFlibcommons-cli-1.2.jar
............此处省略80个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)