Sha256: 4c510f8b98fb9ced0b375a2a50e87e55596a4412314f5149b57602ecfc42d499
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
module Asposewordsjavaforruby module InsertNestedFields def initialize() # The path to the documents directory. data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/' # Create new document. doc = Rjb::import('com.aspose.words.Document').new builder = Rjb::import("com.aspose.words.DocumentBuilder").new(doc) # Insert few page breaks (just for testing) breakType = Rjb::import("com.aspose.words.BreakType") for i in 0..4 builder.insertBreak(breakType.PAGE_BREAK) end # Move DocumentBuilder cursor into the primary footer. headerFooterType = Rjb::import("com.aspose.words.HeaderFooterType") builder.moveToHeaderFooter(headerFooterType.FOOTER_PRIMARY) # We want to insert a field like this: # { IF {PAGE} <> {NUMPAGES} "See Next Page" "Last Page" } field = builder.insertField("IF ") builder.moveTo(field.getSeparator()) builder.insertField("PAGE") builder.write(" <> ") builder.insertField("NUMPAGES") builder.write(" \"See Next Page\" \"Last Page\" ") # Finally update the outer field to recalcaluate the final value. Doing this will automatically update # the inner fields at the same time. field.update() # Save the document. doc.save(data_dir + "InsertNestedFields Out.doc") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asposewordsjavaforruby-0.0.5 | lib/asposewordsjavaforruby/insertnestedfields.rb |