Class: Jod

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/doctopdf.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeJod

Returns a new instance of Jod.



17
18
19
20
21
# File 'lib/doctopdf.rb', line 17

def initialize
  oconfiguration = org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration.new()
  @officeManager = oconfiguration.buildOfficeManager()
  @officeManager.start()
end

Class Method Details

.finalizeObject



31
32
33
# File 'lib/doctopdf.rb', line 31

def self.finalize
  @officeManager.stop()
end

Instance Method Details

#convert_doc(file) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/doctopdf.rb', line 23

def convert_doc(file)
  tempdir = File.join(Dir.tmpdir, 'doctopdf')
  output_file = File.join(tempdir, File.basename(file) + Time.now.to_i.to_s + rand(100).to_s + '.pdf')
  converter = org.artofsolving.jodconverter.OfficeDocumentConverter.new(@officeManager)
  converter.convert(java.io.File.new(file), java.io.File.new(output_file))
  return output_file
end