This step-by-step tutorial provides details on how to convert PPTX to SVG using Java. You can convert PPTX to SVG format such that each slide in the PPTX is saved as a separate SVG image. The following steps can be used to export PPTX to SVG in Java in your applications.
Steps to Convert PPTX to SVG using Java
- Install Aspose.Slides from the Maven repository
- Load an input PPTX using the Presentation class object
- Access all the slides in the PPTX one by one for conversion to SVG
- Save each slide of PPTX to SVG image
These steps configure the library and then initialize the Presentation class object to load the PPTX file. In the next step it accesses each slide and creates the SVG image file for each slide.
Code to Convert PPTX to SVG using Java
import com.aspose.slides.License; | |
import com.aspose.slides.Presentation; | |
import com.aspose.slides.ISlide; | |
import java.io.FileOutputStream; | |
public class HowToConvertPptxToSvgUsingJava { | |
public static void main() throws Exception { //main() function for HowToConvertPptxToSvgUsingJava | |
// Instantiate a license to remove trial version watermark after converting PPTX to SVG | |
License license = new License(); | |
license.setLicense("Aspose.Slides.lic"); | |
// Load the PPTX file to convert all slides to SVG | |
Presentation PptxToSVG = new Presentation("ExportPptxToSVG.pptx"); | |
for (int index = 0; index < PptxToSVG.getSlides().size(); index++) | |
{ | |
// Access slides to export PPTX to SVG | |
ISlide SlideToSVG = PptxToSVG.getSlides().get_Item(index); | |
try (FileOutputStream outputStream = new FileOutputStream("slide-" + index + ".svg")) { | |
// Save PPTX as SVG with writeAsSvg method | |
SlideToSVG.writeAsSvg(outputStream); | |
} | |
} | |
} | |
} |
This Java code snippet loads the input PPTX file without requiring the installation of the MS PowerPoint application. Furthermore, the feature to generate SVG from PPTX using Java is helpful when you need to create scalable images without changing the quality of the image.
In this tutorial, we have learned how to generate SVG from PPTX using Java. If you want to work with presentations in any other language like C#, have a look at the article on how to add image watermark in PPTX Presentation Using C#.