资源简介
Spring boot 在线预览办公文件(doc、docx、xls、xlsx、pdf等),转化效果个人觉得比较理想
代码片段和文件信息
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter;
import static org.artofsolving.jodconverter.office.OfficeUtils.SERVICE_DESKTOP;
import static org.artofsolving.jodconverter.office.OfficeUtils.cast;
import static org.artofsolving.jodconverter.office.OfficeUtils.toUnoProperties;
import static org.artofsolving.jodconverter.office.OfficeUtils.toUrl;
import java.io.File;
import java.util.Map;
import org.artofsolving.jodconverter.office.OfficeContext;
import org.artofsolving.jodconverter.office.OfficeException;
import org.artofsolving.jodconverter.office.OfficeTask;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XStorable;
import com.sun.star.io.IOException;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.XComponent;
import com.sun.star.task.ErrorCodeIOException;
import com.sun.star.util.CloseVetoException;
import com.sun.star.util.XCloseable;
public abstract class AbstractConversionTask implements OfficeTask {
private final File inputFile;
private final File outputFile;
public AbstractConversionTask(File inputFile File outputFile) {
this.inputFile = inputFile;
this.outputFile = outputFile;
}
protected abstract Map getLoadProperties(File inputFile);
protected abstract Map getStoreProperties(File outputFile XComponent document);
public void execute(OfficeContext context) throws OfficeException {
XComponent document = null;
try {
document = loadDocument(context inputFile);
modifyDocument(document);
storeDocument(document outputFile);
} catch (OfficeException officeException) {
throw officeException;
} catch (Exception exception) {
throw new OfficeException(“conversion failed“ exception);
} finally {
if (document != null) {
XCloseable closeable = cast(XCloseable.class document);
if (closeable != null) {
try {
closeable.close(true);
} catch (CloseVetoException closeVetoException) {
// whoever raised the veto should close the document
}
} else {
document.dispose();
}
}
}
}
private XComponent loadDocument(OfficeContext context File inputFile) throws OfficeException {
if (!inputFile.exists()) {
throw new OfficeException(“input document not found“);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-29 15:55 file-online-preview\
文件 438 2018-01-22 09:18 file-online-preview\.gitignore
目录 0 2018-01-30 13:29 file-online-preview\.idea\
文件 11 2018-01-29 15:50 file-online-preview\.idea\.name
文件 805 2018-01-29 15:55 file-online-preview\.idea\compiler.xm
文件 306 2018-01-29 15:55 file-online-preview\.idea\encodings.xm
目录 0 2018-01-31 14:57 file-online-preview\.idea\inspectionProfiles\
目录 0 2018-01-29 15:55 file-online-preview\.idea\libraries\
文件 495 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__antlr_antlr_2_7_7.xm
文件 608 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__ch_qos_logback_logback_classic_1_1_11.xm
文件 587 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__ch_qos_logback_logback_core_1_1_11.xm
文件 539 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_beust_jcommander_1_12.xm
文件 555 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_fasterxm
文件 677 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_fasterxm
文件 635 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_fasterxm
文件 663 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_fasterxm
文件 736 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_fasterxm
文件 536 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_github_junrar_junrar_0_7.xm
文件 532 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_google_guava_guava_19_0.xm
文件 579 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_jayway_jsonpath_json_path_2_2_0.xm
文件 585 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_thoughtworks_xstream_xstream_1_3_1.xm
文件 733 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xm
文件 547 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__commons_cli_commons_cli_1_1.xm
文件 547 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__commons_cli_commons_cli_1_2.xm
文件 576 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__commons_codec_commons_codec_1_10.xm
文件 624 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__commons_httpclient_commons_httpclient_3_1.xm
文件 536 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__commons_io_commons_io_1_4.xm
文件 536 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__commons_io_commons_io_2_4.xm
文件 605 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__commons_logging_commons_logging_1_1_1.xm
文件 619 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__commons_logging_commons_logging_api_1_1.xm
文件 495 2018-01-29 15:55 file-online-preview\.idea\libraries\Maven__dom4j_dom4j_1_6_1.xm
............此处省略1380个文件信息
- 上一篇:IP-COM-X3原厂编辑器固件
- 下一篇:Qt Creator快速入门
相关资源
- Spring study code
- 关于Spring相关的论文
- 经典的基于ARM的uboot移植教程
- 基于SpringMVC的用户三次登录失败案例
- Spring boot in action 随书源码
- Maven+SpringMVC的HelloWord最简单入门小(
- 基于struts+spring+ibatits宠物商城
- IDEA 搭建Spring MVC环境二
- SpringMVC-Helloworld224190
- bootstrap-fileinput+strtus2实现多文件上传
- springcloud全家桶(eureka+ribbon+feign+hys
- AdminEx - 响应式设计bootstrap3后台管理模
- zw_SpringMVC.zip
- Elements of Computational Statistics(Springe
- STM32网络升级BootLoader
- Spring.Net结合NHibernate完整代码
- 三大框架(最新)
- springboot+Shiro 实现动态授权
- TMS320VC5509A(LQFP)Bootloader测试程序
- Maven+SSM+Bootstrap项目
- spring boot+mybatis+thymeleaf+apache shiro开发
- SpringBoot+mybatis+redis+rabbitmq
- JPetStore (Struts + Spring + Hibernate)版
- bootstrap-table
- SSHStruts、Spring、Hibernate三大框架整合
- SpringBoot+Vue前后端分离,使用SpringSe
- Spring boot -- 基于AngularJS的网络商城系
- Maven之Spring Boot_AngularJS--网络商城系统
- springboot+websocket实现聊天室
- Spring MVC4 中文高清 PDF (压缩包)
评论
共有 条评论