This is a sample showing how to validate a PDF document against PDF/A sub-format using Qoppa’s jPDFPreflight library.

PDF/A is the format for PDF for Long-term Preservation.

Validate against PDF/A-1b:

PreflightResults results = pdfPreflight.verifyDocument(new PDFA_1_B_Verification(), null);

Validate against PDF/A-2b:

PreflightResults results = pdfPreflight.verifyDocument(new PDFA_2_B_Verification(), null);

Validate against PDF/A-3b:

PreflightResults results = pdfPreflight.verifyDocument(new PDFA_3_B_Verification(), null);

Here is a full Java sample showing how to validate against PDF/A-1b:

package jPDFPreflightSamples;
 
import java.io.IOException;
 
import com.qoppa.pdf.PDFException;
import com.qoppa.pdfPreflight.PDFPreflight;
import com.qoppa.pdfPreflight.profiles.PDFA_1_B_Verification;
import com.qoppa.pdfPreflight.results.PreflightResults;
 
public class ValidatePDFA {
 
	public static void main(String[] args)
	{
		try
		{
			System.out.println("Starting");
			PDFPreflight pdfPreflight = new PDFPreflight("C:\\input.pdf", null);
 
			// Validate the document
			PreflightResults results = pdfPreflight.verifyDocument(new PDFA_1_B_Verification(), null);
			if (results.isSuccessful())
			{
				System.out.println("PDF is compliant");
			}
			else
			{
				System.out.println("PDF is not compliant");
				// Add annotations to the document
				results.addResultAnnotations();
				// Append report to the document
				results.appendPreflightReport(612, 792);
				// Save the PDF document with annotations and report
				pdfPreflight.saveDocument("C:\\validationreport.pdf"); 
			}
		}
		catch(PDFException pdfe)
		{
			System.out.println(pdfe);
		}
		catch(IOException ioe)
		{
			System.out.println(ioe);
		}
		catch(Throwable t)
		{
			System.out.println(t);
		}
 
	}
 
}