How to Convert OpenDocument Presentation (.odp) to PDF via Java Application
OpenDocument Format (ODF) is a document file format that contains OpenDocument presentations. It consists of a collection of pages (slides) containing text, graphics and multimedia content, which can be displayed in front of an audience in a controlled manner. But at work, you may need to convert it to a PDF document. Today I will introduce a method for you to convert ODP documents to PDF format quickly and efficiently. The following are the steps and methods I have organized, and the Java code is attached for your reference. OK, here we go.
Programming Environment
First, 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.
Method 1:
Introduced manually.
Download Free Spire. Presentation
for Java locally, unzip it, and find the Spire. Presentation.jar file in the lib
folder. Open the following interface in IDEA, and import the jar file in the
local path into the Java program:
Method 2:
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.
<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.free</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
Convert ODP to PDF
You can convert ODP to PDF using Spire.Presentation for Java
in an easy and quick manner by following the steps listed below.
- Create a Presentation object.
- Load a sample ODP document using Presentation.loadFromFile() method.
- Save the document as PDF using Presentation.saveToFile() method.
Full Code
Java
import com.spire.presentation.*;
public class ODPtoPDF {
public static void main(String[] args) throws Exception {
//Create a Presentation instance
Presentation presentation = new Presentation();
//Load a sample ODP file
presentation.loadFromFile("Jupiter.odp",FileFormat.ODP);
//Save it as PDF
presentation.saveToFile("result.pdf", FileFormat.PDF);
}
}
Effective Shot
Conclusion:
In this post,
you have learned how to convert OpenDocument presentation (.odp) to PDF in Java.
Not only that, we also have other functions, such as, Java:
Convert Images (PNG, JPG, BMP, etc.) to PowerPoint, Java:
Convert PowerPoint Presentations to PDF and
so on. Apart from that, if you'd like to learn more, you can visit this link
to explore more about for Spire. Presentation for Java.
Comments
Post a Comment