The code samples below create a presentation with a slide, add an image with a picture frame and applies animation to it.

VSTO Example

Using VSTO, take the following steps:
  1. Create a presentation.
  2. Add an empty slide.
  3. Add a picture shape to the slide.
  4. Apply animation to the picture.
  5. Write the presentation to disk.

//Creating empty presentation
            PowerPoint.Presentation pres = Globals.ThisAddIn.Application.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);

            //Add a blank slide
            PowerPoint.Slide sld = pres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank);

            //Add Picture Frame
            PowerPoint.Shape PicFrame = sld.Shapes.AddPicture("pic.jpeg",
            Microsoft.Office.Core.MsoTriState.msoTriStateMixed,
            Microsoft.Office.Core.MsoTriState.msoTriStateMixed, 150, 100, 400, 300);

            //Applying animation on picture frame
            PicFrame.AnimationSettings.EntryEffect = Microsoft.Office.Interop.PowerPoint.PpEntryEffect.ppEffectBoxIn;

            //Saving Presentation
            pres.SaveAs("VSTOAnim.ppt", PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
            Microsoft.Office.Core.MsoTriState.msoFalse);


Aspose.Slides for .NET Example

Using Aspose.Slides for .NET, perform the following steps:
  1. Create a presentation.
  2. Access the first slide.
  3. Add an image to a picture collection.
  4. Add a picture shape to the slide.
  5. Apply animation to the picture.
  6. Write the presentation to disk.

//Creating empty presentation
            Presentation pres = new Presentation();

            //Accessing the First slide
            Slide slide = pres.GetSlideByPosition(1);

            //Adding the picture object to pictures collection of the presentation
            Picture pic = new Picture(pres, "pic.jpeg");

            //After the picture object is added, the picture is given a uniqe picture Id
            int picId = pres.Pictures.Add(pic);

            //Adding Picture Frame
            Shape PicFrame = slide.Shapes.AddPictureFrame(picId, 1450, 1100, 2500, 2200);

            //Applying animation on picture frame
            PicFrame.AnimationSettings.EntryEffect = ShapeEntryEffect.BoxIn;

            //Saving Presentation
            pres.Write("AsposeAnim.ppt");


Download

Last edited Jan 1, 2014 at 6:23 AM by asposemarketplace, version 2