Search code examples
javapdfpdfboxpdfa

Checking if a PDF is PDF/A 1-a format or not using PDFBOX in java


I have to check if a pdf file is in PDF/A 1-a format or not using pdfbox or any other free library in java . I have searched a lot on google in this regard but still i couldnt get any code or technique for doing this.

How can I check this in java .


Solution

  • The document from pdfbox shows how to do PDF/A-1b validation:

    https://pdfbox.apache.org/cookbook/pdfavalidation.html

    to do pdf/a-1a validation, you simply change :

      parser.parse();
    

    to:

     parser.parse(Format.PDF_A1A);
    

    I was able to ascertain this from reading the parser source code located here:

    http://grepcode.com/file/repo1.maven.org/maven2/org.apache.pdfbox/preflight/1.8.2/org/apache/pdfbox/preflight/parser/PreflightParser.java