This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/java/conversion/validate-pdf-conformance.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Validate PDF conformance | Nutrient Java SDK

PDF conformance validation verifies that a document actually complies with the archival (PDF/A) or accessibility (PDF/UA) standard it claims. A document that carries a PDF/A or PDF/UA identifier in its metadata isn’t guaranteed to satisfy the standard — files produced by external tools, edited after conversion, or assembled from mixed sources often violate the requirements they declare.

Conformance validation is a common requirement in these workflows:

  • Archive ingestion — Verifying documents before accepting them into long-term storage
  • Compliance auditing — Checking existing document repositories against declared standards
  • Conversion verification — Confirming the output of a PDF/A or PDF/UA conversion pipeline
  • Accessibility programs — Testing documents against PDF/UA before publication

This sample demonstrates how to validate a PDF document against the conformance level it claims, and how to force validation against a specific conformance level.

Validating documents with our Java SDK

Developers can implement this feature by adding a few lines of code to their applications. The SDK validates all PDF/A conformance levels (PDF/A-1 through PDF/A-4) and PDF/UA-1 with a single API, and it produces a detailed report that lists every rule violation it finds.

Preparing the project

Specify a package name and create a new class:

package io.nutrient.Sample;

Import Nutrient Java SDK. It’s recommended to specify the actual classes used, but using a wildcard to include everything is also possible:

import io.nutrient.sdk.Document;
import io.nutrient.sdk.validation.PdfValidator;
import io.nutrient.sdk.validation.PdfValidationResult;
import io.nutrient.sdk.enums.PdfValidationConformance;
import io.nutrient.sdk.exceptions.NutrientException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class ValidatePdfConformance {

Create the main function and specify that it can throw a NutrientException. This exception can be caught in the program logic for custom error management:

public static void main(String[] args) throws NutrientException, IOException {

After the Java application setup, focus on the SDK-specific steps.

Loading the PDF document

Initialize Document using a try-with-resources(opens in a new tab) statement to enable proper lifecycle management of the document instance. The validator only accepts PDF documents; other formats aren’t converted implicitly:

try (Document document = Document.open("input_pdfa_valid.pdf")) {

This path can be absolute or relative. This example loads the file from the application’s working directory.

Validating the claimed conformance

Create a validator instance bound to the document with PdfValidator.set(document). Then call validate(). By default, the validator reads the conformance level the document claims in its metadata and validates against it:

PdfValidator validator = PdfValidator.set(document);
PdfValidationResult result = validator.validate();
System.out.println("Document is valid: " + result.getIsValid());
System.out.println("Validated conformance: " + result.getValidatedConformance());
Files.writeString(Path.of("report.xml"), result.getReport());

The result carries three values:

  • getIsValid() — Whether the document complies with the conformance level it was validated against.
  • getValidatedConformance() — The conformance level the validation ran against. In automatic mode, this is the level detected from the document’s metadata.
  • getReport() — A detailed machine-readable XML report. When the document doesn’t comply, the report lists every problem found during validation.

If the document claims no PDF/A or PDF/UA conformance at all, no validation runs: The result reports the document as not valid, getValidatedConformance() stays at PdfValidationConformance.Auto, and the report explains that there was nothing to validate against.

Forcing a specific conformance level

To check a document against a standard it doesn’t claim — for example, to test whether an archival document is also accessible — set the conformance property before calling validate():

validator.setConformance(PdfValidationConformance.PdfUa1);
PdfValidationResult uaResult = validator.validate();
System.out.println("PDF/UA-1 conformant: " + uaResult.getIsValid());
}
}
}

The sample document is a valid PDF/A file, so the forced PDF/UA-1 check reports it as not conformant — the accessibility standard imposes tagging and structure requirements that archival conformance doesn’t.

The PdfValidationConformance enumeration covers all supported validation targets:

  • PDF/A-1PdfA1a, PdfA1b
  • PDF/A-2PdfA2a, PdfA2u, PdfA2b
  • PDF/A-3PdfA3a, PdfA3u, PdfA3b
  • PDF/A-4PdfA4, PdfA4e, PdfA4f
  • PDF/UA-1PdfUa1
  • AutomaticAuto (validates against the claimed conformance; this is the default)

Error handling

Nutrient Java SDK handles errors with exception handling. The methods presented in this guide throw a NutrientException if a failure occurs — for example, when the document isn’t a PDF or when it’s encrypted. This helps with troubleshooting and implementing error handling logic.

Conclusion

That’s all it takes to verify that a PDF document genuinely complies with the archival or accessibility standard it claims. To produce compliant documents from regular PDF files, refer to the PDF to PDF/A and PDF to PDF/UA guides. You can also download this ready-to-use sample package, which is configured to help you explore the Java SDK and conformance validation capabilities.