Here is a sample code to convert a PDF document to PDF/A using Qoppa’s jPDFPreflight library.

If the conversion was successful, a success message is shown and the PDF-A compliant document is saved as output.
If the conversion was unsuccessful, a failure message is shown and the original document is saved with annotations appended to it as well as a report detailing the issues found in the document.

Convert to PDF/A-1b:

PDFA_1_B_Conversion profile = new PDFA_1_B_Conversion();

Convert to PDF/A-2b:

PDFA_2_B_Conversion profile = new PDFA_2_B_Conversion();

Convert to PDF/A-3b:

PDFA_3_B_Conversion profile = new PDFA_3_B_Conversion();
package jPDFPreflightSamples;
 
import java.io.IOException;
 
import com.qoppa.pdf.PDFException;
import com.qoppa.pdfPreflight.PDFPreflight;
import com.qoppa.pdfPreflight.profiles.PDFAConversionOptions;
import com.qoppa.pdfPreflight.profiles.PDFA_1_B_Conversion;
import com.qoppa.pdfPreflight.results.PreflightResults;
 
public class ConvertToPDFA {
 
	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		try
		{
			System.out.println("Starting");
			PDFPreflight pdfPreflight = new PDFPreflight("C:\\input.pdf", null);
 
			// Create a new conversion profile 
			PDFA_1_B_Conversion profile = new PDFA_1_B_Conversion();
 
			// Set conversion options
			PDFAConversionOptions options = (PDFAConversionOptions) profile.getConversionOptions();
			options.setEmbeddedFiles(PDFAConversionOptions.OPTION_DELETE);
			options.setTransparency(PDFAConversionOptions.OPTION_WARN);
			options.setUnsupportedAnnotations(PDFAConversionOptions.OPTION_DELETE);
                        options.setSignatureFields(PDFAConversionOptions.OPTION_FLATTEN);
 
 
			// Convert the document
			PreflightResults results = pdfPreflight.convertDocument(profile, null);
 
			// Get conversion results
			if (results.isSuccessful())
			{
				System.out.println("PDF was converted successfully");
				// Save the PDF/A Document
				pdfPreflight.saveDocument("C:\\output_pdfa.pdf"); 
			} 
			else 
			{ 
				System.out.println("PDF was not converted, see report"); 
				// Add annotations to the document 
				pdfPreflight.addResultAnnotations(results); 
				// Append report to the document 
				pdfPreflight.appendPreflightReport(results, 612, 792); 
				// Save the PDF document with annotations and report
				pdfPreflight.saveDocument("C:\\conversionreport.pdf"); 
			}
		}
		catch(PDFException pdfe)
		{
			System.out.println(pdfe);
		}
		catch(IOException ioe)
		{
			System.out.println(ioe);
		}
		catch(Throwable t)
		{
			System.out.println(t);
		}
 
	}
 
}