News Category

Java: Convert PowerPoint to XPS

2022-09-26 07:03:00 Written by  support iceblue
Rate this item
(0 votes)

XPS (XML Paper Specification) is a fixed-format document described by an XML-based language. It maintains a consistent appearance for documents, which is an ideal file format for publishing, archiving and transmitting. This article will demonstrate how to programmatically convert PowerPoint to XPS using Spire.Presentation for Java.

Install Spire.Presentation for Java

First of all, you're required to add the Spire.Presentation.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>9.4.5</version>
    </dependency>
</dependencies>
    

Convert PowerPoint to XPS

The detailed steps are as follows:

  • Create a Presentation instance.
  • Load a sample PowerPoint document using Presentation.loadFromFile() method.
  • Save the PowerPoint document to XPS using Presentation.saveToFile(java.lang.String file, FileFormat fileFormat) method.
  • Java
import com.spire.presentation.*;

public class PowerPointtoXPS {
    public static void main(String[] args) throws Exception{

        //Create a Presentation instance
        Presentation ppt = new Presentation();

        //Load a sample PowerPoint file
        ppt.loadFromFile("E:\\Files\\test.pptx");

        //Save to XPS file
        ppt.saveToFile("toXPS.xps", FileFormat.XPS);
        ppt.dispose();
    }
}

Java: Convert PowerPoint to XPS

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Additional Info

  • tutorial_title:
Last modified on Monday, 26 September 2022 01:03