我想做一些文档转换工作,使用 jodconverter & open office 4。我已经在我的 windows 7 上的 C:\Program Files (x86)\OpenOffice 4 上安装了 open office。在任务管理器中我看到了 soffice.bin* 的过程32
当我运行我的演示将 doc 文件转换为 html 文件时。我发生了这个异常:
log4j:WARN No appenders could be found for logger (org.artofsolving.jodconverter.office.OfficeManager).
log4j:WARN Please initialize the log4j system properly.
一月 07, 2016 10:27:49 上午 org.artofsolving.jodconverter.office.OfficeConnection connect
信息: connected: 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1'
Exception in thread "main" org.artofsolving.jodconverter.office.OfficeException: could not load document: asdf.doc
at org.artofsolving.jodconverter.AbstractConversionTask.loadDocument(AbstractConversionTask.java:93)
at org.artofsolving.jodconverter.AbstractConversionTask.execute(AbstractConversionTask.java:53)
at org.artofsolving.jodconverter.office.ExternalOfficeManager.execute(ExternalOfficeManager.java:70)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:72)
at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:63)
at demo.OfficeDocumentManager.conveterOfficeDocument(OfficeDocumentManager.java:84)
at demo.Test.main(Test.java:9)
我检查了 jodconverter 的源代码:
private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
if (!inputFile.exists()) {
throw new OfficeException("input document not found");
}
XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
Map<String,?> loadProperties = getLoadProperties(inputFile);
XComponent document = null;
try {
document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
} catch (IllegalArgumentException illegalArgumentException) {
throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
} catch (ErrorCodeIOException errorCodeIOException) {
throw new OfficeException("could not load document: " + inputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
} catch (IOException ioException) {
throw new OfficeException("could not load document: " + inputFile.getName(), ioException);
}
if (document == null) {
throw new OfficeException("could not load document: " + inputFile.getName());
}
return document;
}
当我调试这些代码时。我发现该文档始终为空。我要在这里加载的文件是存在且可读的。谁能告诉我为什么我不能加载文件?