I have the same thing, but it uses Microsoft Office.
And as you mention, MS specifically states that office is not to be used
server-side. It's doable, but sure as heck not supported.
How complicated is the code to integrate with OpenOffice?
Actually not that bad once you get your head around UNO and the API. The
basic code is:
------start---------
string sourceURI = "file:///c:/temp/input.doc";
string targetURI = "file:///c:/temp/output.pdf";
//Duh, bootstrap.
XComponentContext localContext =
uno.util.Bootstrap.defaultBootstrap_InitialComponentContext();
//Get local service manager
XMultiComponentFactory localSM = localContext.getServiceManager();
// get urlresolver service from local service manager
XUnoUrlResolver urlResolver =
(XUnoUrlResolver)localSM.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver",
localContext);
//using urlresolver, get remote context (this is the remote version of
localcontext)
XComponentContext remoteCCemoteCC =
(XComponentContext)urlResolver.resolve(
"uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext");
//get the remote service manager
XMultiServiceFactory remoteSF =
(XMultiServiceFactory)remoteCC.getServiceManager();
//get the desktop on the remote instance of openoffice
XComponentLoader desktop = (XComponentLoader)remoteSF.createInstance(
"com.sun.star.frame.Desktop");
PropertyValue[] loadProps = new PropertyValue[2];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new uno.Any(true);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "ReadOnly";
loadProps[1].Value = new uno.Any(true);
//load the document in a hidden, readonly manner
XComponent comp = desktop.loadComponentFromURL(sourceURI,
"_blank", //target frame
0, //flags
loadProps); //Properties
XStorable str = (XStorable)comp;
//See
http://wiki.services.openoffice.org/wiki/Framework/Article/Filter/Filter
List_OOo_2_1
string exportFilter = "writer_pdf_Export";
PropertyValue[] props = new PropertyValue[1];
props[0] = new PropertyValue();
props[0].Name = "FilterName";
props[0].Value = new uno.Any(exportFilter);
//save the document as a pdf
str.storeToURL(targetURI, props);
//close up shop.
comp.dispose();
------end---------
The entire production webservice w/logging, error handling, etc. is only
a couple hundred lines.
I wonder if it could be ported to the i and run in headless mode?
Not sure. We obviously run it in headless mode since it's serverside,
but I never looked at running openoffice on i.
-Walden
--
Walden H Leverich III
Tech Software
(516) 627-3800 x3051
WaldenL@xxxxxxxxxxxxxxx
http://www.TechSoftInc.com
Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)
As an Amazon Associate we earn from qualifying purchases.