-
Notifications
You must be signed in to change notification settings - Fork 3
Render Slide As SVG Image
Aspose edited this page Mar 4, 2014
·
2 revisions
Aspose.Slides for .NET is used to create presentation files, complete with slides. These slides can be viewed by opening presentations using Microsoft PowerPoint. But sometimes, developers may also need to view slides as SVG images in their favorite image viewer. In such cases, Aspose.Slides for .NET lets you export an individual slide to an SVG image.
To generate an SVG image from any desired slide with Aspose.Slides.Pptx for .NET, please follow the steps below:
- Create an instance of the Presentation class.
- Obtain the desired slide's reference by using its ID or index(here we are using slide index 2).
- Get the SVG image in a memory stream.
- Save the memory stream to file.
using (PresentationEx pres = new PresentationEx(MyDir+"Slides Test Presentation.pptx"))
{
//Access the second slide
SlideEx sld = pres.Slides[1];
//Create a memory stream object
MemoryStream SvgStream = new MemoryStream();
//Generate SVG image of slide and save in memory stream
sld.WriteAsSvg(SvgStream);
SvgStream.Position = 0;
//Save memory stream to file
using (Stream fileStream = System.IO.File.OpenWrite(MyDir+ "PresentatoinTemplate.svg"))
{
byte[] buffer = new byte[8 * 1024];
int len;
while ((len = SvgStream.Read(buffer, 0, buffer.Length)) > 0)
{
fileStream.Write(buffer, 0, len);
}
}
SvgStream.Close();
}
Below is the result of code:
Download