PDF/A is an ISO-standardized version of PDF for digital preservation and long-term archiving of electronic documents. Unlike standard PDF, PDF/A prohibits features unsuitable for long-term archiving, such as font linking and encryption, and requires that certain features be included, such as embedded fonts and color profiles.
There are several conformance levels defined across multiple PDF/A versions:
PDF/A-1 (ISO 19005-1) — based on PDF 1.4, with conformance levels a (accessible) and b (basic)
PDF/A-2 (ISO 19005-2) — based on PDF 1.7, adding conformance level u (Unicode)
PDF/A-3 (ISO 19005-3) — same as PDF/A-2 but allows embedding arbitrary file formats as attachments
PDF/A-4 (ISO 19005-4) — based on PDF 2.0, with the e (engineering) and f (embedded files) variants
Using GroupDocs.Metadata for Java you can detect whether a loaded PDF document conforms to a PDF/A standard and find out its exact version and conformance level.
Detecting PDF/A conformance
The following steps and Java code sample show how to detect the PDF/A type of a PDF document in a Java application:
try(Metadatametadata=newMetadata(Constants.InputPdfA)){PdfRootPackageroot=metadata.getRootPackageGeneric();if(root.getPdfType().isPdfA()){System.out.println(String.format("PDF/A version: %s",root.getPdfType().getPdfFormat()));}else{System.out.println("The document is not PDF/A compliant.");}}
For a PDF/A-1b document the code prints PDF/A version: PdfA1B.
isPdfA returns true for any value from the PDF/A group, and isPdfX returns true for any value from the PDF/X group.
Detecting PDF/A type and version information together
The code sample below shows how to read the PDF/A conformance information together with general PDF file format properties.
try(Metadatametadata=newMetadata(Constants.InputPdfA)){PdfRootPackageroot=metadata.getRootPackageGeneric();PdfTypePackagepdfType=root.getPdfType();System.out.println(String.format("File format : %s",pdfType.getFileFormat()));System.out.println(String.format("PDF version : %s",pdfType.getVersion()));System.out.println(String.format("MIME type : %s",pdfType.getMimeType()));System.out.println(String.format("PDF format : %s",pdfType.getPdfFormat()));System.out.println(String.format("Is PDF/A : %s",pdfType.isPdfA()));System.out.println(String.format("Is PDF/X : %s",pdfType.isPdfX()));}
Checking a folder of PDF documents
Before PDF files are moved to an archive, it is common to check which of them are already PDF/A. The following code sample prints the detected format of every PDF file in a folder.
Filefolder=newFile(Constants.InputPath);for(Filefile:folder.listFiles((dir,name)->name.toLowerCase().endsWith(".pdf"))){try(Metadatametadata=newMetadata(file.getAbsolutePath())){PdfRootPackageroot=metadata.getRootPackageGeneric();PdfFormatformat=root.getPdfType().getPdfFormat();if(root.getPdfType().isPdfA()){System.out.println(String.format("%s: %s",file.getName(),format));}else{System.out.println(String.format("%s: not PDF/A (%s)",file.getName(),format));}}}
Note
GroupDocs.Metadata reports the conformance level that the document declares about itself. The check does not validate the file against the PDF/A standard, so use a dedicated validator if you need proof of compliance.
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured Java library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.