How to Convert PDF to PDF/A in Java

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.


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


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