PDF/A is a kind of PDF format designed for archiving and long-term preservation of electronic documents. Unlike paper documents that are easily damaged or smeared, PDF/A format ensures that documents can be reproduced in exactly the same way even after long-term storage. This article will demonstrate how to convert PDF to PDF/A-1A, 2A, 3A, 1B, 2B and 3B compliant PDF using Free Spire.PDF for Java.
Import jar dependency (2 Methods)
● Download the Free Spire.PDF for Java and unzip it.Then add the Spire.Pdf.jar file to your project as dependency.
● Directly 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>4.3.0</version>
</dependency>
</dependencies>
Code Snippet
import com.spire.pdf.conversion.PdfStandardsConverter;
public class ConvertPdfToPdfA {
public static void main(String[] args) {
//Specify input file path
String inputFile = "C:/Users/Administrator/Desktop/sample.pdf";
//Specify output folder
String outputFolder = "C:/Users/Administrator/Desktop/Output/";
//Create a PdfStandardsConverter instance, passing in the input file as a parameter
PdfStandardsConverter converter = new PdfStandardsConverter(inputFile);
//Convert to PdfA1A
converter.toPdfA1A(outputFolder + "ToPdfA1A.pdf");
//Convert to PdfA1B
converter.toPdfA1B(outputFolder + "ToPdfA1B.pdf");
//Convert to PdfA2A
converter.toPdfA2A(outputFolder + "ToPdfA2A.pdf");
//Convert to PdfA2B
converter.toPdfA2B(outputFolder + "ToPdfA2B.pdf");
//Convert to PdfA3A
converter.toPdfA3A(outputFolder + "ToPdfA3A.pdf");
//Convert to PdfA3B
converter.toPdfA3B(outputFolder + "ToPdfA3B.pdf");
}
}
Top comments (0)