How to Convert PDF to PDF/A in Java

<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>
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");
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store