by aspose_seo (5 Submissions)
Category: Internet/HTML
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Fri 3rd April 2009
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Adding new shapes in slides using Serialization.
API Declarations
- Create some shape using MS-PowerPoint and save the presentation
- Read the presentation and its shape using Aspose.Slides
- Serialize the shape
- Create a new presentation and add the serialized shape in it.
//Read the source presentation
Presentation srcPres = new Presentation("c:\\source.ppt");
//Read the shape
Slide srcSld = srcPres.GetSlideByPosition(1);
Shape srcShape = srcSld.Shapes[0];
//Serialize the shape
MemoryStream ms = new MemoryStream();
srcShape.Serialize(ms);
//Create a target presentation
Presentation targetPres = new Presentation();
//Add a serialized shape inside the target presentation
Slide targetSld = targetPres.GetSlideByPosition(1);
ms.Position = 0;
targetSld.Shapes.Add(ms);
//Write the target presentation on disk
targetPres.Write("c:\\target.ppt");
[VB.NET]
'Read the source presentation
Dim srcPres As Presentation = New Presentation("c:\source.ppt")
'Read the shape
Dim srcSld As Slide = srcPres.GetSlideByPosition(1)
Dim srcShape As Shape = srcSld.Shapes(0)
'Serialize the shape
Dim ms As MemoryStream = New MemoryStream()
srcShape.Serialize(ms)
'Create a target presentation
Dim targetPres As Presentation = New Presentation()
'Add a serialized shape inside the target presentation
Dim targetSld As Slide = targetPres.GetSlideByPosition(1)
ms.Position = 0
targetSld.Shapes.Add(ms)
'Write the target presentation on disk
targetPres.Write("c:\target.ppt")