Sha256: 476cafbbdc0313483444ae3c1b0fe5d2363551953708979b4d5ada0d1fa9f7dd

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

module Asposeslidesjava
  module RemoveSlides
    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    

    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    

    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    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asposeslidesjava-0.0.2 lib/asposeslidesjava/Slides/removeslides.rb
asposeslidesjava-0.0.1 lib/asposeslidesjava/Slides/removeslides.rb