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

PDF/X is the format for Prepress Graphics File Interchange.

Validate against PDF/X-1a:2001:

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

Validate against PDF/X-1a:2003:

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

Validate against PDF/X-3:2002:

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

Validate against PDF/X-3:2003:

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

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

package jPDFPreflightSamples;
 
import java.io.IOException;
 
import com.qoppa.pdf.PDFException;
import com.qoppa.pdfPreflight.PDFPreflight;
import com.qoppa.pdfPreflight.profiles.PDFX_1a_2001;
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 PDFX_1a_2001(), 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);
		}
 
	}
 
}