This is a Java sample program using Qoppa’s PDF Preflight library jPDFPreflight. It opens PDF, validates against the PDF/UA sub-format (ISO 14289), then adds annotations on the PDF where errors are found and attaches a Preflight validation report at the end of
the PDF and saves it as a new file.

Note: This PDF/UA verification process will only check the items that can be verified programmatically. There are additional items that can only be verified manually and that are not included in this validation, such as: Color contrast, logical reading order. Software tools exist for aiding such a verification process.

 
// Load PDF document
PDFPreflight pdfPreflight = new PDFPreflight("C:\\tmp\\input.pdf", null);
 
// Validate the document
PreflightResults results = pdfPreflight.verifyDocument(new PDF_UA_Verification(), null);
if (results.isSuccessful())
{ 
 System.out.println("PDF is PDF/UA compliant");
}
else
{
 System.out.println("PDF is not PDF/UA compliant");
 // 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:\\tmp\\validationreport.pdf"); 
}

Download Full Java Program to Verify PDF/UA Format