Module: Asposeslidesjava::Properties

Defined in:
lib/asposeslidesjava/Presentation/properties.rb

Instance Method Summary collapse

Instance Method Details

#add_custom_propertiesObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/asposeslidesjava/Presentation/properties.rb', line 63

def add_custom_properties()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
   
    # Instantiate the Presentation class that represents the presentation
    pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + "HelloWorld.pptx")

    # Getting Document Properties
    dp = pres.getDocumentProperties()

    # Adding Custom properties
    dp.set_Item("New Custom" , 12)
    dp.set_Item("My Name","Mudassir")
    dp.set_Item("Custom", 124)

    # Saving presentation
    save_format = Rjb::import('com.aspose.slides.SaveFormat')
    pres.save(data_dir + "CustomDemo.pptx",save_format.Pptx)

    puts "Added custom properties, please check output file."
end

#get_propertiesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/asposeslidesjava/Presentation/properties.rb', line 14

def get_properties()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
   
    # Instantiate the Presentation class that represents the presentation
    pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + "HelloWorld.pptx")

    # Create a reference to IDocumentProperties object associated with Presentation
    dp = pres.getDocumentProperties()

    # Display the builtin properties
    puts "Category : " + dp.getCategory().to_s
    puts "Current Status : " + dp.getContentStatus().to_s
    puts "Creation Date : " + dp.getCreatedTime().to_string
    puts "Author : " + dp.getAuthor().to_s
    puts "Description : " + dp.getComments().to_s
    puts "KeyWords : " + dp.getKeywords().to_s
    puts "Last Modified By : " + dp.getLastSavedBy().to_s
    puts "Supervisor : " + dp.getManager().to_s
    puts "Modified Date : " + dp.getLastSavedTime().to_string
    puts "Presentation Format : " + dp.getPresentationFormat().to_s
    puts "Last Print Date : " + dp.getLastPrinted().to_string
    puts "Is Shared between producers : " + dp.getSharedDoc().to_s
    puts "Subject : " + dp.getSubject().to_s
    puts "Title : " + dp.getTitle().to_s
end

#initializeObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/asposeslidesjava/Presentation/properties.rb', line 3

def initialize()
    # Accessing Built-in Properties 
    get_properties()

    # Modifying Built-in Properties
    update_properties()

    # Adding Custom Document Properties
    add_custom_properties()
end

#remove_propertyObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/asposeslidesjava/Presentation/properties.rb', line 84

def remove_property()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
   
    # Instantiate the Presentation class that represents the presentation
    pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + "HelloWorld.pptx")

    # Getting Document Properties
    dp = pres.getDocumentProperties()

    # Getting property name at particular index
    property_name = dp.getPropertyName(2)

    # Removing selected property
    dp.remove(property_name)

    # Saving presentation
    save_format = Rjb::import('com.aspose.slides.SaveFormat')
    pres.save(data_dir + "RemoveDP.pptx",save_format.Pptx)

    puts "Remove document property, please check output file."
end

#update_propertiesObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/asposeslidesjava/Presentation/properties.rb', line 40

def update_properties()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
   
    # Instantiate the Presentation class that represents the presentation
    pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + "HelloWorld.pptx")

    # Create a reference to IDocumentProperties object associated with Presentation
    dp = pres.getDocumentProperties()

    # Set the builtin properties
    dp.setAuthor ("Aspose.Slides for Java")
    dp.setTitle ("Modifying Presentation Properties")
    dp.setSubject ( "Aspose Subject")
    dp.setComments ( "Aspose Description")
    dp.setManager ( "Aspose Manager")

    # Save your presentation to a file
    save_format = Rjb::import('com.aspose.slides.SaveFormat')
    pres.save(data_dir + "DocProps.pptx", save_format.Pptx)

    puts "Properties have been updated, Please check output file."
end