Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created May 7, 2025 16:30
Show Gist options
  • Save aspose-com-gists/6643792c9988c609f890f8323e48612e to your computer and use it in GitHub Desktop.
Save aspose-com-gists/6643792c9988c609f890f8323e48612e to your computer and use it in GitHub Desktop.
Convert PPTX to EMF in Java
public class main
{
public static void main(String[] args)
{
// The path to the document directory.
String dataDir = "data";
//Out path
String resultPath = dataDir + "Result.emf";
// Instantiate a Presentation object that represents a presentation file. https://reference.aspose.com/slides/java/com.aspose.slides/presentation/#Presentation-java.lang.String-
Presentation presentation = new Presentation(dataDir + "test.pptx");
try {
FileOutputStream fileStream = new FileOutputStream(resultPath);
// Saves the first slide as a metafille by calling the writeAsEmf method. https://reference.aspose.com/slides/java/com.aspose.slides/islide/#writeAsEmf-java.io.OutputStream-
presentation.getSlides().get_Item(0).writeAsEmf(fileStream);
} catch (IOException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (presentation != null) presentation.dispose();
}
//ExEnd:ConvertToEmf
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment