JODConverter is a nice project that deploys OpenOffice to obtain services. It allows converting files from Office to OpenOffice, to pdf, to flash etc.
It can be embedded in a Webservice, in a Website, or driven from a Java program. The JODConverter site offers the possibility to perform online conversion.
Since NeoOffice is a branch of OpenOffice, it works also with it.
Here is a simple example (taken from the JODConverter website and completed by adding the right imports etc. - sorry the indentation is killed from Blogger's editor).
To use it (on a Mac) you need:
- to install NeoOffice
- to download the JODConverter jars
- to start NeoOffice as a service (in a shell, execute:
/Applications/NeoOffice.app/Contents/MacOS/soffice.bin -headless -accept="socket,port=8100;urp;")
- compile and run the following java program (make sure that you include the jars in the library!)
package jod;
import java.io.File;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import java.net.ConnectException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main {
public static void main(String[] args) {
new Main();
}
Main(){
//put here the name of your source file
File inputFile = new File("/Users/ronchet/Desktop/3.5.ppt");
//put here the name of your destination file
File outputFile = new File("/Users/ronchet/Desktop/3.5.pdf");
//Note that for determining which conversion must be applied, JODConverter will use the files'extensions
// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
} catch (ConnectException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
// close the connection
connection.disconnect();
}
}
Just a note: an alternative way to convert slides is to use (within ppt) a VBA script to export the slides into a bunch of jpgs. Here is a such script, and here another version of the same.
Also, for exporting all text, here is another VBA script.
Showing posts with label NeoOffice. Show all posts
Showing posts with label NeoOffice. Show all posts
Wednesday, May 28, 2008
Tuesday, May 27, 2008
Office on Mac - without M$
OpenOffice has been for long time a free alternative to MS Office.
On the Mac it needs to install X11 - which can be a bit annoying. There is though an interesting alternative: NeoOffice. It is an OpenOffice independent branch dedicated to the Mac and based on Aqua. It also opens the new MS formats (e.g. ppx) - OpenOffice does not yet! It also has an interface to Databases (can access a database through JDBC).
NoMu is a nice add on that installs a menu in the finder for launching NeoOffice in a different mode (e.g. as presentation or spreadsheet tool).
Alternatively, you can launch it from the shell as
/Applications/NeoOffice.app/Contents/MacOS/soffice.bin file.doc
/Applications/NeoOffice.app/Contents/MacOS/soffice.bin -impress file.ppt
/Applications/NeoOffice.app/Contents/MacOS/soffice.bin -calc file.xls
NeoOffice is scriptable (in several languages: Basic, Java, Javascript, Python). I found it difficult to find documentation - it took me a lot of frustrating googling hours - until I realized that OpenOffice and StarOffice documentation apply also to NeoOffice - maybe with some differences.
Here are some resources:
On the Mac it needs to install X11 - which can be a bit annoying. There is though an interesting alternative: NeoOffice. It is an OpenOffice independent branch dedicated to the Mac and based on Aqua. It also opens the new MS formats (e.g. ppx) - OpenOffice does not yet! It also has an interface to Databases (can access a database through JDBC).
NoMu is a nice add on that installs a menu in the finder for launching NeoOffice in a different mode (e.g. as presentation or spreadsheet tool).
Alternatively, you can launch it from the shell as
/Applications/NeoOffice.app/Contents/MacOS/soffice.bin file.doc
/Applications/NeoOffice.app/Contents/MacOS/soffice.bin -impress file.ppt
/Applications/NeoOffice.app/Contents/MacOS/soffice.bin -calc file.xls
NeoOffice is scriptable (in several languages: Basic, Java, Javascript, Python). I found it difficult to find documentation - it took me a lot of frustrating googling hours - until I realized that OpenOffice and StarOffice documentation apply also to NeoOffice - maybe with some differences.
Here are some resources:
- Basic programming language documentation (StarOffice)
- OpenOffice wiki
- OpenOffice forum with a section on Macros and APIs
Subscribe to:
Posts (Atom)
