jodconverter ,openoffice ,openoffice 实现文档在线预览

hjjh 发布于 2016/12/22 17:49
阅读 1K+
收藏 0


public class Test {
public static void main(String[] args){
office2pdf2html();
//office2html();
}

public static void office2pdf2html() {
String sourceFile = "D:\\test\\xlsTest.xlsx";
String destFile = "F:\\office\\1.pdf";
String htmlFile = "WebContent\\1.html";
// office文件转pdf
int result = Office2PDFUtil.office2PDF(sourceFile, destFile);
if(result == 0) {
System.out.println("office转PDF成功");
// pdf转html
if(Pdf2htmlEXUtil.pdf2html(destFile, htmlFile)) {
System.out.println("pdf转html成功");
}
else 
System.out.println("pdf转html失败");

} else if(result == -1) {
System.out.println("找不到源文件, 或url.properties配置错误");
} else {
System.out.println("office转PDF失败");
}
//System.out.println(ClearHtml2Div.clearFormat(htmlStr, docImgPath));
}

public static void office2html() {
System.out.println(Doc2HtmlUtil.office2HtmlString(new File("F:/office/EXCEL示例文件.xlsx"), "F:/office/test"));
}
}


报错信息

十二月 22, 2016 5:41:23 下午 com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection connect

INFO: connected
Exception in thread "main" com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed: could not save output document; OOo errorCode: 283
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:142)
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.convertInternal(OpenOfficeDocumentConverter.java:120)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:104)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:74)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:70)
at util.Office2PDFUtil.office2PDF(Office2PDFUtil.java:92)
at util.Test.office2pdf2html(Test.java:16)
at util.Test.main(Test.java:7)
Caused by: com.sun.star.task.ErrorCodeIOException: 
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:182)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:148)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:344)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:313)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:101)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:652)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:154)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:136)
at com.sun.proxy.$Proxy7.storeToURL(Unknown Source)
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.storeDocument(OpenOfficeDocumentConverter.java:156)
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:140)
... 7 more

加载中
返回顶部
顶部