我想用 openOffice 将 doc 格式更改为 docx 格式。我使用了 jodconverter-local-4.4.2 和 jodconverter-core-4.4.2 来实现这个功能,但是我遇到了一个异常,我的源代码如下。
public static void test(){
String inputFile = "C:\\Users\\Administrator\\Desktop\\test\\111.doc";
String outputFile = "C:\\Users\\Administrator\\Desktop\\test\\监区长办公会.docx";
LocalOfficeManager localOfficeManager = LocalOfficeManager.builder()
.install()
.officeHome("C:\\Program Files (x86)\\OpenOffice 4") //your path to openoffice
.build();
try {
localOfficeManager.start();
final DocumentFormat format
= DocumentFormat.builder()
.from(DefaultDocumentFormatRegistry.DOCX)
.build();
LocalConverter
.make()
.convert(new FileInputStream(new File(inputFile)))
.as(DefaultDocumentFormatRegistry.getFormatByMediaType("application/msword"))
.to(new File(outputFile))
.as(format)
.execute();
System.err.println("end ...............");
} catch (OfficeException ex) {
ex.printStackTrace();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} finally {
OfficeUtils.stopQuietly(localOfficeManager);
}
}
11:25:55.875 [main] DEBUG org.jodconverter.core.office.AbstractOfficeManagerPool - Returning office manager to the pool...
org.jodconverter.core.office.OfficeException: Could not store document: 监区长办公会.docx; errorCode: 2074
at org.jodconverter.local.task.LocalConversionTask.storeDocument(LocalConversionTask.java:183)
at org.jodconverter.local.task.LocalConversionTask.execute(LocalConversionTask.java:119)
at org.jodconverter.local.office.LocalOfficeManagerPoolEntry.doExecute(LocalOfficeManagerPoolEntry.java:120)
at org.jodconverter.core.office.AbstractOfficeManagerPoolEntry.lambda$execute$0(AbstractOfficeManagerPoolEntry.java:80)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.sun.star.task.ErrorCodeIOException:
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:173)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:139)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:334)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:303)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:87)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:636)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:146)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:128)
at com.sun.proxy.$Proxy11.storeToURL(Unknown Source)
有人可以帮我吗?谢谢大家。