3.25.  PDF/A


There are many tools for checking whether a PDF document complies with one of the PDF standards (PDF/A, PDF/X etc.). But only a few of them can be used for automated tests. PDFUnit uses the PDFBox's 'Preflight' parser internally to check the compliance with PDF/A.

Information on the 'Preflight' parser can be found on the project web site https://pdfbox.apache.org/1.8/cookbook/pdfavalidation.html.

A PDF/A validation starts with the following method:

// Validate PDF/A-1a and PDF/A-1b:


The next example checks compliance with PDF/A-1a:

public void compliesWithPDFA() throws Exception {
  String fileName = "pdf_a/documentUnderTest.pdf"; 1
            .pdfStandard(PDFA_1A)                  2


Files can be tested but not byte-arrays or streams.


The validation can be parameterized using one of the two constants PDFA_1A and PDFA_1B.

The error messages from the Preflight parser are passed through to PDFUnit. The images below show examples in Eclipse and in an HTML browser:

A PDF/A validation can also be applied to all PDF documents in a given folder:

public void compliesWithPDFA_InFolder() throws Exception {
  File foldertoWatch = new File("pdf_a-1b");
  FilenameFilter filenameFilter = new FilenameContainingFilter("tn0001");