Module: Asposeslidesjava::CloneShape

Defined in:
lib/asposeslidesjava/Shapes/cloneshape.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/asposeslidesjava/Shapes/cloneshape.rb', line 3

def initialize()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Shapes/'
            
    # Create an instance of Presentation class
    srcPres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')

    # Accessing source slide shape collection
    sourceShapes = srcPres.getSlides().get_Item(0).getShapes()

    blankLayout = srcPres.getMasters().get_Item(0).getLayoutSlides().getByType(Rjb::import('com.aspose.slides.SlideLayoutType').Blank)

    destSlide = srcPres.getSlides().addEmptySlide(blankLayout)

    # Accessing destination slide shape collection
    destShapes = destSlide.getShapes()

    # Clone shapes by using different methods
    destShapes.addClone(sourceShapes.get_Item(1), 50, 150 + sourceShapes.get_Item(0).getHeight())
    destShapes.addClone(sourceShapes.get_Item(2))
    destShapes.addClone(sourceShapes.get_Item(3), 50, 200, 50, 50)
    destShapes.insertClone(0, sourceShapes.get_Item(0), 50, 150)

    # Write the presentation as a PPTX file 
    save_format = Rjb::import('com.aspose.slides.SaveFormat')
    srcPres.save(data_dir + "CloneShape.pptx", save_format.Pptx)

    puts "Cloned shape, please check the output file."
end