In our daily work, we may find that some devices have strict requirements on the PDF version. Therefore, we need to convert PDF file between different versions for compatibility purpose. This article will show how to change the PDF version by using Free Spire.PDF for Java (Supports the PDF versions from 1.0 to 1.7).
Installation
Method 1: Download the Free Spire.PDF for Java and unzip it.Then add the Spire.Pdf.jar file to your project as dependency.
Method 2: You can also add the jar dependency to maven project by adding the following configurations to the pom.xml.
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.pdf.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>
Change PDF Version:
package com.spire.pdf;
public class ChangePdfVersion {
public static void main(String[] args) {
//Create a PdfDocument object
PdfDocument document = new PdfDocument();
//Load a sample PDF file
document.loadFromFile("test.pdf");
//Change the PDF version to 1.6
document.getFileInfo().setVersion(PdfVersion.Version_1_6);
//Save to file
document.saveToFile("PdfVersion.pdf", FileFormat.PDF);
document.close();
}
}
Top comments (0)