Module: Asposeslidesjava::CloneSlides

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

Instance Method Summary collapse

Instance Method Details

#clone_to_aonther_positionObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/asposeslidesjava/Slides/cloneslides.rb', line 31

def clone_to_aonther_position()
    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')

    # Clone the desired slide to the end of the collection of slides in the same presentation
    slides = pres.getSlides()
    
    # Clone the desired slide to the specified index in the same presentation
    slides.insertClone(2, pres.getSlides().get_Item(1))

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

    puts "Slide has been cloned, please check the output file."
end

#clone_to_end_of_presentationObject



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

def clone_to_end_of_presentation()
    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')

    # Clone the desired slide to the end of the collection of slides in the same presentation
    slides = pres.getSlides()
    slides.addClone(pres.getSlides().get_Item(0))

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

    puts "Slide has been cloned, please check the output file."
end

#clone_to_other_presentation_at_end_of_existing_slideObject

In Another Presentation at the End of the Existing Slides



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/asposeslidesjava/Slides/cloneslides.rb', line 51

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

    # Instantiate Presentation class for destination PPTX (where slide is to be cloned)
    dest_pres = Rjb::import('com.aspose.slides.Presentation').new

    # Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
    slds = dest_pres.getSlides()

    slds.addClone(src_pres.getSlides().get_Item(0))

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

    puts "Slide has been cloned, please check the output file."
end

#initializeObject



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

def initialize()
    # Within the Same Presentation from One Position to the End
    clone_to_end_of_presentation()

    # From One Position to Anther within the Same Presentation
    clone_to_aonther_position()

    # In Another Presentation at the End of the Existing Slides
    clone_to_other_presentation_at_end_of_existing_slide()
end