|
| 1 | +using Syncfusion.Presentation; |
| 2 | + |
| 3 | +//Create an instance for PowerPoint |
| 4 | +IPresentation pptxDoc = Presentation.Create(); |
| 5 | +//Add a blank slide to Presentation |
| 6 | +ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); |
| 7 | + |
| 8 | +IShape textboxShape = slide.AddTextBox(200, 50, 150, 50); |
| 9 | +IParagraph paragraph = textboxShape.TextBody.AddParagraph(); |
| 10 | +//Adds a TextPart to the paragraph |
| 11 | +ITextPart textPart = paragraph.AddTextPart(); |
| 12 | +//Adds text to the TextPart |
| 13 | +textPart.Text = "Hello World!"; |
| 14 | +//Access the animation sequence to create effects |
| 15 | +ISequence sequence = slide.Timeline.MainSequence; |
| 16 | +//Add bounce effect to the shape |
| 17 | +IEffect bounceEffect = sequence.AddEffect(textboxShape, EffectType.Bounce, EffectSubtype.None, EffectTriggerType.WithPrevious); |
| 18 | + |
| 19 | + |
| 20 | +IShape textboxShape1 = slide.AddTextBox(200, 150, 150, 50); |
| 21 | +//Adds paragraph to the textbody of textbox |
| 22 | +IParagraph paragraph1 = textboxShape1.TextBody.AddParagraph(); |
| 23 | +//Adds a TextPart to the paragraph |
| 24 | +ITextPart textPart1 = paragraph1.AddTextPart(); |
| 25 | +//Adds text to the TextPart |
| 26 | +textPart1.Text = "New Textbox Added"; |
| 27 | +//Access the animation sequence to create effects |
| 28 | +ISequence sequence1 = slide.Timeline.MainSequence; |
| 29 | +//Add bounce effect to the shape |
| 30 | +IEffect bounceEffect1 = sequence1.AddEffect(textboxShape1, EffectType.Swivel, EffectSubtype.None, EffectTriggerType.WithPrevious); |
| 31 | + |
| 32 | + |
| 33 | +FileStream pictureStream = new FileStream(@"..\..\..\Data\Image.jpeg", FileMode.Open); |
| 34 | +//Adds the picture to a slide by specifying its size and position. |
| 35 | +IPicture picture = slide.Pictures.AddPicture(pictureStream, 200, 250, 300, 200); |
| 36 | +//Access the animation sequence to create effects |
| 37 | +ISequence sequence2 = slide.Timeline.MainSequence; |
| 38 | +//Add bounce effect to the shape |
| 39 | +IEffect bounceEffect2 = sequence2.AddEffect(picture as IShape, EffectType.Bounce, EffectSubtype.None, EffectTriggerType.WithPrevious); |
| 40 | + |
| 41 | + |
| 42 | +//Save the PowerPoint Presentation as stream |
| 43 | +FileStream outputStream = new FileStream(@"..\..\..\Data\Sample.pptx", FileMode.Create); |
| 44 | +pptxDoc.Save(outputStream); |
0 commit comments