---
title: "Validate PDF conformance | Nutrient Python SDK"
canonical_url: "https://www.nutrient.io/guides/python/conversion/validate-pdf-conformance/"
md_url: "https://www.nutrient.io/guides/python/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 Python 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 Python 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

Import Nutrient Python SDK:

```python

from nutrient_sdk import Document
from nutrient_sdk import PdfValidator
from nutrient_sdk import PdfValidationConformance
from nutrient_sdk import NutrientException

```

## Loading the PDF document

Use Python’s [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers) to enable proper lifecycle management of the document instance. The validator only accepts PDF documents; other formats aren’t converted implicitly:

```python

def main():
    try:
        with Document.open("input_pdfa_valid.pdf") as document:

```

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:

```python

            validator = PdfValidator.set(document)

            result = validator.validate()
            print(f"Document is valid: {result.is_valid}")
            print(f"Validated conformance: {result.validated_conformance}")

            with open("report.xml", "w", encoding="utf-8") as report_file:
                report_file.write(result.report)

```

The result carries three values:

- `is_valid` — Whether the document complies with the conformance level it was validated against.

- `validated_conformance` — The conformance level the validation ran against. In automatic mode, this is the level detected from the document’s metadata.

- `report` — 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, `validated_conformance` 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()`:

```python

            validator.conformance = PdfValidationConformance.PDF_UA1

            ua_result = validator.validate()
            print(f"PDF/UA-1 conformant: {ua_result.is_valid}")
    except NutrientException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

```

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** — `PDF_A1A`, `PDF_A1B`

- **PDF/A-2** — `PDF_A2A`, `PDF_A2U`, `PDF_A2B`

- **PDF/A-3** — `PDF_A3A`, `PDF_A3U`, `PDF_A3B`

- **PDF/A-4** — `PDF_A4`, `PDF_A4E`, `PDF_A4F`

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

- **Automatic** — `AUTO` (validates against the claimed conformance; this is the default)

## Error handling

Nutrient Python SDK handles errors with exception handling. The methods presented in this guide raise 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/python/conversion/pdf-to-pdf-a.md) and [PDF to PDF/UA](https://www.nutrient.io/guides/python/conversion/pdf-to-pdf-ua.md) guides. You can also download [this ready-to-use sample package](https://www.nutrient.io/downloads/samples/python/validate-pdf-conformance.zip), which is configured to help you explore the Python SDK and conformance validation capabilities.
---

## Related pages

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

