Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Created November 19, 2008 23:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save brianleroux/26817 to your computer and use it in GitHub Desktop.
Save brianleroux/26817 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