Skip to content

Instantly share code, notes, and snippets.

@doxavore
Forked from brianleroux/gist:26817
Created September 6, 2011 15:57
Show Gist options
  • Save doxavore/1197963 to your computer and use it in GitHub Desktop.
Save doxavore/1197963 to your computer and use it in GitHub Desktop.
require 'java'
require 'jodconverter-cli-2.2.1.jar'
def convert(file_in,file_out)
inputFile = java.io.File.new(file_in)
outputFile = java.io.File.new(file_out)
# connect to an OpenOffice.org instance running on port 8100
connection = com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection.new(8100)
connection.connect()
# convert
converter = com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.new(connection)
converter.convert(inputFile, outputFile)
# close the connection
connection.disconnect();
end
convert 'test.txt', 'test.pdf'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment