× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.