---
title: "Validate PDF conformance | Nutrient Java SDK"
canonical_url: "https://www.nutrient.io/guides/java/conversion/validate-pdf-conformance/"
md_url: "https://www.nutrient.io/guides/java/conversion/validate-pdf-conformance.md"
last_updated: "2026-08-21T00:00:00.000Z"
description: "How to validate PDF/A and PDF/UA conformance using Nutrient Java SDK."
---

# Validate PDF conformance

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:

```java

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:

```java

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:

```java

    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](https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html) statement to enable proper lifecycle management of the document instance. The validator only accepts PDF documents; other formats aren’t converted implicitly:

```java

        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:

```java

            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()`:

```java

            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-1** — `PdfA1a`, `PdfA1b`

- **PDF/A-2** — `PdfA2a`, `PdfA2u`, `PdfA2b`

- **PDF/A-3** — `PdfA3a`, `PdfA3u`, `PdfA3b`

- **PDF/A-4** — `PdfA4`, `PdfA4e`, `PdfA4f`

- **PDF/UA-1** — `PdfUa1`

- **Automatic** — `Auto` (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](https://www.nutrient.io/guides/java/conversion/pdf-to-pdf-a.md) and [PDF to PDF/UA](https://www.nutrient.io/guides/java/conversion/pdf-to-pdf-ua.md) guides. You can also download [this ready-to-use sample package](https://www.nutrient.io/downloads/samples/java/validate-pdf-conformance.zip), which is configured to help you explore the Java SDK and conformance validation capabilities.
---

## Related pages

- [Nutrient Java SDK conversion guides](/guides/java/conversion.md)
- [Converting CAD files to PDF](/guides/java/conversion/cad-to-pdf.md)
- [Converting file streams to PDF/UA](/guides/java/conversion/convert-from-file-stream-to-pdf-ua.md)
- [Converting email files to PDF](/guides/java/conversion/email-to-pdf.md)
- [Converting a document from XLSX to PDF format](/guides/java/conversion/excel-document-to-pdf.md)
- [Converting HTML to PDF](/guides/java/conversion/html-to-pdf.md)
- [Converting a document from Markdown to PDF format](/guides/java/conversion/markdown-to-pdf.md)
- [Converting PDF documents to Excel format for data analysis](/guides/java/conversion/pdf-to-excel-document.md)
- [Converting PDF documents to HTML format for web publishing](/guides/java/conversion/pdf-to-html.md)
- [Converting PDF documents to image format](/guides/java/conversion/pdf-to-image.md)
- [Converting PDF documents to Markdown format](/guides/java/conversion/pdf-to-markdown.md)
- [Converting PDF documents to PDF/A format](/guides/java/conversion/pdf-to-pdf-a.md)
- [Converting PDF documents to PDF/UA format](/guides/java/conversion/pdf-to-pdf-ua.md)
- [Converting PDF documents to PowerPoint presentations](/guides/java/conversion/pdf-to-powerpoint-document.md)
- [Converting a document from PDF to DOCX format](/guides/java/conversion/pdf-to-word-document.md)
- [Converting a document from PPTX to PDF format](/guides/java/conversion/powerpoint-document-to-pdf.md)
- [Preparing and troubleshooting PDF/A conversion](/guides/java/conversion/prepare-and-troubleshoot-pdf-a-conversion.md)
- [Converting a Word document to PDF while preserving comments](/guides/java/conversion/word-document-to-pdf-including-comments.md)
- [Converting a document from DOCX to PDF/UA format](/guides/java/conversion/word-document-to-pdf-ua.md)
- [Converting a document from DOCX to PDF format](/guides/java/conversion/word-document-to-pdf.md)

