Sha256: 99da35b6f026528c4c94b218012e3d3b9f5326855c55a0716b60a1a757031c05

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

module Asposepdfjava
  module SetExpiration
    def initialize()
    	# The path to the documents directory.
        data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
        
        # Open a pdf document.
        doc = Rjb::import('com.aspose.pdf.Document').new(data_dir + "input1.pdf")

        javascript = Rjb::import('com.aspose.pdf.JavascriptAction').new(
            "var year=2014;
            var month=4;
            today = new Date();
            today = new Date(today.getFullYear(), today.getMonth());
            expiry = new Date(year, month);
            if (today.getTime() > expiry.getTime())
            app.alert('The file is expired. You need a new one.');")
        doc.setOpenAction(javascript)
        
        # save update document with new information
        doc.save(data_dir + "set_expiration.pdf")

        puts "Update document information, please check output file."
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asposepdfjava-0.0.2 lib/asposepdfjava/Document/setexpiration.rb
asposepdfjava-0.0.1 lib/asposepdfjava/Document/setexpiration.rb