Metadata-Version: 2.4
Name: page-validation
Version: 0.0.1
Classifier: Development Status :: 3 - Alpha
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Rust
License-File: LICENSE
Summary: Python bindings for the page_validation PDF/A and PDF/UA validator
Keywords: page,pdf,validation
Author-email: Joseph Barbier <joseph@ysunflower.com>
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://josephbarbierdarnal.github.io/page-validation/
Project-URL: Homepage, https://josephbarbierdarnal.github.io/page-validation/
Project-URL: Issues, https://github.com/josephbarbierdarnal/page-validation/issues
Project-URL: Repository, https://github.com/josephbarbierdarnal/page-validation

# page-validation

Python bindings for [`page`](https://crates.io/crates/page_validation), a PDF/A and PDF/UA validator.

<br>

## Validate a PDF

```python
import page

report = page.validate_file("document.pdf")
print(report)

if not report.checks_passed:
    for failure in report.failures:
        print(f"[{failure.rule_id}] {failure.message}")
```

`validate_file()` and `validate_bytes()` infer the PDF/A or PDF/UA profile from the document's XMP metadata. They raise `page.ValidationError` when the profile declaration is missing, malformed, or unsupported, or when the input cannot be read or parsed.

To select the profile yourself, use the explicit-profile variant:

```python
import page

report = page.validate_file_with_profile(
    "document.pdf",
    page.ValidationProfile.PDF_A_1B,
)
```

The explicit-profile functions always return a `ValidationReport`. Parser, operational, and conformance problems are represented in `report.failures`.

You can export the results as JSON with:

```python
with open("report.json", "w") as f:
    f.write(report.to_json())
```

<br>

## Configure safety limits

All validation functions accept an optional `SafetyLimits` instance:

```python
limits = page.SafetyLimits(
    max_input_size=100 * 1024 * 1024,
    max_decoded_stream_size=32 * 1024 * 1024,
    max_object_count=500_000,
    max_reference_depth=128,
)

report = page.validate_file("document.pdf", limits)
```

