This is a fork of the original https://github.com/amardaxini/convert_office with slight modifications to allow it to be used as a gem using Bundler.
Two additional configuration keys have also been added, with the default values:
:asynchronous=>true # whether to run the java command asynchronously or not
:verbose=>false # whether to print out some additional runtime information (useful for tracking down problems)
Note that this has only been tested on Rails 2.3.14 with Bundler included - although its expected to work on Rails 3, some additional work is required to automatically include the convert_office rake task with Railsties
It is a ruby Wrapper of [jodconverter][1] Which is used to convert office format to another office format/html [1]: http://www.artofsolving.com/opensource/jodconverter.
Add to your Gemfile:
gem 'convert_office', :git=>'[email protected]:stuzart/convert_office.git'
JDK 1.5.x or 1.6.x
OpenOffice 2,3 or greater
Start Office with headless mode.
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
Configuration
-------------
These are the default settings which can be overwritten in your enviroment configuration file.
ConvertOffice::ConvertOfficeConfig.options = {
:java_bin => "java", # java binary
:nailgun =>false, # for nailgun support
:soffice_port=>8100, # Open office port no
:asynchronous=>true, # wait for the java system command to finish or not
:verbose=>false # display some additional runtime information
}
Example
If destination file is known.destination file consist valid file format
ConvertOffice::ConvertOfficeFormat.new.convert(src_file,dest_file)
If format is known then
ConvertOffice::ConvertOfficeFormat.new.convert(src_file,"",format)
To see valid format for conversion.
ConvertOffice::ConvertOfficeFormat.display_valid_format(input file name/format optional field)
To speed up conversion process using nailgun server,do following steps
./script/plugin install git://github.com/amardaxini/nailgun.git
Start nailgun server.Before starting nailgun server make sure that your classpath environment variable set and point to jre/lib
rake nailgun
script/nailgun start
you have to overwrite Configuration make nailgun option to true Now after making nailgun option true run
rake convert_office
script/convet_office_nailgun
Copyright (c) 2010 [amardaxini][1], released under the MIT license [1]: http://railstech.com