3
回答
java远程调用openoffice服务将word文件转换成pdf问题
开发十年,就只剩下这套Java开发体系了   

启动openoffice服务的命令


soffice -headless -accept="socket,host=192.168.1.129,port=8100;urp;" -nofirststartwizard

关键java程序


OpenOfficeConnection connection = new SocketOpenOfficeConnection("192.168.1.129", 8100);

看构造函数是支持java程序远程调用openoffice服务的,但是实际测试出现异常

word文件和java程序都在应用服务器192.168.1.130上,openoffice服务在192.168.1.129上


Exception in thread "main" com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed: could not load input document
	at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:131)
	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)
Caused by: com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.
	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.$Proxy5.loadComponentFromURL(Unknown Source)
	at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadDocument(OpenOfficeDocumentConverter.java:150)
	at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:127)
	... 6 more


后来发现,在openoffice服务器上也放一份word文件,就可以成功转换了,并且转换生成的pdf文件也在openoffice服务器上

如此以来,java调用openoffice服务将word文件转换成pdf,必须保证openoffice服务和文件在同一个服务器上???



举报
小龙在线
发帖于2年前 3回/1K+阅
顶部