Sha256: 2c4352f7ce2b3dd44d117c1f2444238d60ecc05a20504b759e1c8b899198e689

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

module Asposeslidesjava
  module CloneShape
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asposeslidesjava-0.0.2 lib/asposeslidesjava/Shapes/cloneshape.rb
asposeslidesjava-0.0.1 lib/asposeslidesjava/Shapes/cloneshape.rb