Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/0d94617a0f89dfbdc56663bd9dc37c28 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/0d94617a0f89dfbdc56663bd9dc37c28 to your computer and use it in GitHub Desktop.
Convert PPTX to EMF in Java with Aspose.Slides for Java
import com.aspose.slides.*;
public class PptxToEmfConverter {
public static void main(String[] args) {
// Path to the source PPTX file
String sourceFile = "example.pptx";
// Output folder for EMF files
String outputDir = "output_emf";
// Load the presentation
Presentation presentation = new Presentation(sourceFile);
// Prepare EMF save options
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.EMF);
saveOptions.setImageResolution(300); // Set DPI
saveOptions.setScaleX(1.0);
saveOptions.setScaleY(1.0);
// Ensure output directory exists
new java.io.File(outputDir).mkdirs();
// Convert each slide to EMF
for (int i = 0; i < presentation.getSlides().size(); i++) {
ISlide slide = presentation.getSlides().get_Item(i);
String emfPath = outputDir + java.io.File.separator + "slide_" + (i + 1) + ".emf";
slide.getImage(saveOptions).save(emfPath);
System.out.println("Saved: " + emfPath);
}
// Release resources
presentation.dispose();
System.out.println("Conversion completed successfully.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment