Spire.PDF for Java 4.8.7 provides the PdfDocument.saveToFile() method to support converting PDF to OFD. This article will demonstrate how to do it with Java codes.
BEFORE CODING
We need to create a development
environment by downloading and installing JDK 1.8.0 and Intellij IDEA. Then add
a Jar called Spire.Pdf.jar to IDEA and there are two methods to finish it. One
is that downloading the package of Spire.PDF
for Java from the link, finding Spire.Pdf.jar in the “lib” folder and then
manually adding it to IDEA. The other is that creating a Maven project in IDEA,
typing the following codes in the pom.xml file and finally clicking the button
“import changes”.
<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.Pdf </artifactId>
<version>4.8.7</version>
</dependency>
</dependencies>
USING THE CODE
import com.spire.pdf.FileFormat;
import com.spire.pdf.PdfDocument;
public class ToOFD {
public static void main(String[] args) {
//Create a PdfDocument instance
PdfDocument pdf = new PdfDocument();
//Load a PDF file
pdf.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.pdf");
//Convert to OFD and save the resulting document to a specified path
pdf.saveToFile("output/ConvertPDFToOFD.ofd", FileFormat.OFD);
}
}Output
No comments:
Post a Comment