Render a Slide as an SVG Image

Contents
[ ]

SVG—an acronym for Scalable Vector Graphics—is a standard graphics type or format used to render two-dimensional images. SVG stores images as vectors in XML with details that define their behavior or appearance.

SVG is one of the few formats for images that meets very high standards in these terms: scalability, interactivity, performance, accessibility, programmability, and others. For these reasons, it is commonly used in web development.

You may want to use SVG files when you need to

  • print your presentation in a very large format. SVG images can scale up to any resolution or level. You get to resize SVG images as many times as necessary without sacrificing quality.
  • use charts and graphs from your slides in different mediums or platforms. Most readers can interpret SVG files.
  • use the smallest possible sizes of images. SVG files are generally smaller than their high-resolution equivalents in other formats, especially those formats based on bitmap (JPEG or PNG).

Aspose.Slides for Node.js via Java allows you to export slides in your presentations as SVG images. Go through these steps to generate SVG images:

  1. Create an instance of the Presentation class.
  2. Iterate through all the slides in the presentation.
  3. Write every slide to its own SVG file through FileOutputStream.

This sample code in JavaScript shows you how to convert PPT to SVG using Aspose.Slides:

var pres = new aspose.slides.Presentation("pres.pptx");
try {
    for (var index = 0; index < pres.getSlides().size(); index++) {
        var slide = pres.getSlides().get_Item(index);
        var fileStream = java.newInstanceSync("java.io.FileOutputStream", ("slide-" + index) + ".svg");
        try {
            slide.writeAsSvg(fileStream);
        } finally {
            fileStream.close();
        }
    }
} catch (e) {console.log(e);
} finally {
    if (pres != null) {
        pres.dispose();
    }
}