Module: Asposeslidesjava::RemoveSlides

Defined in:
lib/asposeslidesjava/Slides/removeslides.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
# File 'lib/asposeslidesjava/Slides/removeslides.rb', line 3

def initialize()
    # Using Slides Collection to Remove Slide by Index
    remove_slide_by_index()

    # Using Slides Collection to Remove Slide by ID
    remove_slide_by_id()
end

#remove_slide_by_idObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/asposeslidesjava/Slides/removeslides.rb', line 30

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

    # Removing a slide using its slide index
    pres.getSlides().removeAt(1)

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

    puts "Removed slide by ID, please check the output file."
end

#remove_slide_by_indexObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/asposeslidesjava/Slides/removeslides.rb', line 11

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

    # Accessing a slide using its slide index
    slide = pres.getSlides().get_Item(0)

    # Removing a slide using its reference
    pres.getSlides().remove(slide)

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

    puts "Document has been created, please check the output file."
end