Module: Asposewordsjavaforruby::SimpleMailMerge

Defined in:
lib/asposewordsjavaforruby/simplemailmerge.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



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

def initialize()
    mail_merge()
end

#mail_mergeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/asposewordsjavaforruby/simplemailmerge.rb', line 7

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

    # Open the document.
    doc = Rjb::import('com.aspose.words.Document').new(data_dir + "MailMerge.doc")
    # Fill the fields in the document with user data.
    doc.getMailMerge().execute(
        Array["FullName", "Company", "Address", "Address2", "City"],
        Array["James Bond", "MI5 Headquarters", "Milbank", "", "London"]
    )
    # Saves the document to disk.
    doc.save(data_dir + "MailMerge Out.docx")
end