<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
The filter "writer_pdf_Export" does not works while another filter
"MS Word 97" does, using the java Uno framework within Tomcat.
<br>
e.g. the conversion odt > doc or docx > doc works well
<br>
Simply changing the filter name from "MS Word 97" to
"writer_pdf_Export" and the target file extensions doc to pdf does
not work!
<br>
The conversion to pdf produce a
com.sun.star.task.ErrorCodeIOException ... as shonw below.<br>
<br>
The same code executed has a standalone java application using the
loader com.sun.star.lib.loader.Loader is working for both filters!
We have checked all possible write permission and found no possible
issue since all processes belong to the same user.<br>
<br>
Context: MacOS Lion, LibreOffice3.5.4 Java-Tomcat
<br>
<br>
Note that the command line with the writer_pdf_Export filter pdf
works well!:
<br>
/Applications/LibreOffice.app/Contents/MacOS/soffice --headless
--convert-to pdf:writer_pdf_Export *.docx
<br>
<br>
Libreoffice is launched with the command line:
<br>
/Applications/LibreOffice.app/Contents/MacOS/soffice --norestore
--nofirststartwizard --nologo --headless
--accept=socket,host=localhost,port=7396;urp
<br>
<br>
The code follows after the exception.<br>
<br>
The exception:
<br>
com.sun.star.task.ErrorCodeIOException:
<br>
at
com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:177)<br>
at
com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:143)
<br>
at
com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:338)<br>
at
com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:307)<br>
at
com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:91)<br>
at
com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:640)<br>
at
com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:150)<br>
at
com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:132)<br>
at $Proxy8.storeAsURL(Unknown Source)
<br>
at
com.artegis.rs.pdf.PdfGenerator.convert2pdfWithDaemon(PdfGenerator.java:622)<br>
at
com.artegis.rs.pdf.PdfGenerator.getPdfFile(PdfGenerator.java:299)
<br>
at
com.artegis.rs.servlet.UploadServlet.doPost(UploadServlet.java:442)
<br>
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
<br>
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
<br>
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br>
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br>
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)<br>
at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)<br>
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)<br>
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)<br>
at
com.artegis.infra.classes.PageForwarder.forward(PageForwarder.java:234)
<br>
at
com.artegis.infra.servlet.ControllerServlet.doControl(ControllerServlet.java:1453)<br>
at
com.artegis.infra.servlet.ControllerServlet.doPost(ControllerServlet.java:775)<br>
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
<br>
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
<br>
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br>
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br>
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)<br>
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<br>
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)<br>
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br>
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br>
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)<br>
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)<br>
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)<br>
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
<br>
at java.lang.Thread.run(Thread.java:680)
<br>
<br>
The Java code:
<br>
/*
<br>
* java -Dcom.sun.star.lib.loader.unopath="<i class="moz-txt-slash"><span
class="moz-txt-tag">/</span>Applications/LibreOffice.app/Contents/MacOS<span
class="moz-txt-tag">/</span></i>" -classpath
:Users/bv/apache-tomcat-6.0.29/lib/ridl.jar:Users/bv/apache-tomcat-6.0.29/lib/unoil.jar:Users/bv/apache-tomcat-6.0.29/lib/juh.jar:Users/bv/apache-tomcat-6.0.29/lib/jurt.jar:.:<i
class="moz-txt-slash"><span class="moz-txt-tag">/</span>Users/bv/Downloads<span
class="moz-txt-tag">/</span></i> com.sun.star.lib.loader.Loader
test.Test
<br>
*/
<br>
package test;
<br>
import java.io.File;
<br>
import com.sun.star.beans.PropertyValue;
<br>
import com.sun.star.beans.XPropertySet;
<br>
import com.sun.star.bridge.XUnoUrlResolver;
<br>
import com.sun.star.comp.helper.Bootstrap;
<br>
import com.sun.star.frame.XComponentLoader;
<br>
import com.sun.star.frame.XStorable;
<br>
import com.sun.star.lang.XComponent;
<br>
import com.sun.star.lang.XMultiComponentFactory;
<br>
import com.sun.star.uno.UnoRuntime;
<br>
import com.sun.star.uno.XComponentContext;
<br>
<br>
public class Test {
<br>
public static void main(String[] args) {
<br>
try {
<br>
File file = new
File("/opt/regis/base/root/templates/docx/invoice/events/invoice.docx");
<br>
<br>
XComponentContext xContext =
Bootstrap.createInitialComponentContext(null);
<br>
XMultiComponentFactory xLocalServiceManager =
xContext.getServiceManager();
<br>
Object urlResolver =
xLocalServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",
xContext);
<br>
XUnoUrlResolver xUrlResolver = (XUnoUrlResolver)
UnoRuntime.queryInterface(XUnoUrlResolver.class, urlResolver);
<br>
Object initialObject =
xUrlResolver.resolve("uno:socket,host=localhost,port=7396;urp;StarOffice.ServiceManager");<br>
XMultiComponentFactory xOfficeFactory =
(XMultiComponentFactory)
UnoRuntime.queryInterface(XMultiComponentFactory.class,
initialObject);
<br>
Object desktop =
xOfficeFactory.createInstanceWithContext("com.sun.star.frame.Desktop",
xContext);
<br>
XComponentLoader xCompLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class, desktop);
<br>
String sOutputDir = "/tmp/PDFdaemon";
<br>
File outdir = new File(sOutputDir);
<br>
String sOutUrl = <a class="moz-txt-link-rfc2396E"
href="file:///">"file:///"</a>+outdir.getAbsolutePath().replace('\\',
'/');
<br>
String sUrl = <a class="moz-txt-link-rfc2396E"
href="file:///">"file:///"</a>+file.getAbsolutePath().replace('\\',
'/');
<br>
<br>
// Loading the wanted document
<br>
PropertyValue propertyValues[] = new PropertyValue[1];
<br>
propertyValues[0] = new PropertyValue();
<br>
propertyValues[0].Name = "Hidden";
<br>
propertyValues[0].Value = new Boolean(true);
<br>
<br>
Object oDocToStore =
xCompLoader.loadComponentFromURL(sUrl, "_blank", 0, propertyValues);
<br>
<br>
// Getting an object that will offer a simple way to
store
<br>
// a document to a URL.
<br>
XStorable xStorable = (XStorable)
UnoRuntime.queryInterface(XStorable.class, oDocToStore);
<br>
<br>
// Preparing properties for converting the document
<br>
propertyValues = new PropertyValue[2];
<br>
// Setting the flag for overwriting
<br>
propertyValues[0] = new PropertyValue();
<br>
propertyValues[0].Name = "Overwrite";
<br>
propertyValues[0].Value = new Boolean(true);
<br>
// Setting the filter name
<br>
propertyValues[1] = new PropertyValue();
<br>
propertyValues[1].Name = "FilterName";
<br>
// propertyValues[1].Value = "MS Word 97"; // OK
<br>
// String sExtension = "doc";
<br>
propertyValues[1].Value = "writer_pdf_Export";
<br>
String sExtension = "pdf";
<br>
<br>
// Appending the favoured extension to the origin
document name
<br>
int index1 = sUrl.lastIndexOf('/');
<br>
int index2 = sUrl.lastIndexOf('.');
<br>
String sStoreUrl = sOutUrl+sUrl.substring(index1,
index2+1)+sExtension;
<br>
<br>
// Storing and converting the document
<br>
xStorable.storeAsURL(sStoreUrl, propertyValues);
<br>
}
<br>
catch (Exception e) {
<br>
e.printStackTrace();
<br>
}
<br>
System.exit(0);
<br>
}
<br>
}
</body>
</html>