Module: Asposewordsjavaforruby::HelloWorld

Defined in:
lib/asposewordsjavaforruby/helloworld.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
# File 'lib/asposewordsjavaforruby/helloworld.rb', line 3

def initialize()
    # Create document.
    print_hello_world()
end


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/asposewordsjavaforruby/helloworld.rb', line 8

def print_hello_world()
    data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
    
    #Create a blank document.
    document = Rjb::import('com.aspose.words.Document').new()
    
    #DocumentBuilder provides members to easily add content to a document.
    builder = Rjb::import('com.aspose.words.DocumentBuilder').new(document)
    
    #Write a new paragraph in the document with the text "Hello World!"
    builder.writeln("Hello World!")
    
    # Save the document in DOCX format. The format to save as is inferred from the extension of the file name.
    # Aspose.Words supports saving any document in many more formats.
    document.save(data_dir + "HelloWorld.docx") 
end