Module: Asposewordsjavaforruby::RemoveField

Defined in:
lib/asposewordsjavaforruby/removefield.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/asposewordsjavaforruby/removefield.rb', line 3

def initialize()
    # The path to the documents directory.
    data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/'

    # Open the document.
    doc = Rjb::import('com.aspose.words.Document').new(data_dir + "Field.RemoveField.doc")

    #ExStart
    #ExFor:Field.Remove
    #ExId:DocumentBuilder_RemoveField
    #ExSummary:Removes a field from the document.
    field = doc.getRange().getFields().get(0)
    # Calling this method completely removes the field from the document.
    field.remove()
    #ExEnd

    # Save the document.
    doc.save(data_dir + "Field.RemoveField Out.doc")
end