views:

308

answers:

2
+2  Q: 

OpenOffice in Java

I need a Java interface to the OpenOffice document conversion which would equal to a manual (Open... and then Save As...) as well as access to the PDF generation.

The following are some example of what I want to achieve.

1) Open one type of document (fx. OpenOffice Writer document or Microsoft Office document) onto memory and save it in another supported format.

2) Open one type of document into memory and export it as PDF.

I have gone through http://api.openoffice.org but didn't get any material which can help me to get started. I also tried JODConverter but it requires me to run OpenOffice as a service. I wold prefer to include all the core functionality of OpenOffice in one JAR file so that that the user can use my application without installing or running openoffice on their PC.

What would be a URL/code snippet from where I can get tutorials to get started?

Also do I have to add some JAR files? Will the application work even if I don't have OpenOffice installed on my PC?

A: 

I once used OpenOffice for MS Word to PDF conversion. Although it was the only free solution, I wasn't quite satisfied with the resulting PDF file, specially when your document has complex bidi scripts.

For conversion, as far as I can remember, there was two possible ways. One to use OS pipes and the other was socket or something. I don't have my code right now, but the only thing you need is to search in that URL. You should first launch an OpenOffice executable file (I just followed a simple turorial in OpenOffice wiki) with some parameters, and then run your Java application, using provided Java libraries.

Mohsen
+4  A: 

You might want to have a look at NOA (Nice Office Access). It's a Java API that wraps OO.o's native Java API to be easier to use. It allows you to quickly "remote control" OO.o.

Also tell me if i have to add some jars?

Yes, that is documented.

Will the application work even if i dont have open office not installed on my pc?

No, the application requires a running (!) instance of OO.o, as it essentially remote-controls OO.o. The instance can in theory run on another computer (controlled via network).

sleske