Catalog PyPI
Back to packageRELEASE DETAILS

0.3.0

PyPI

aems-pdf-annotator

Shared PDF annotation engine for AEMS: schema-driven verdict markers, page-anchored highlights, and LLM-output payload contract

aemsannotationeducationgradingpdf
Published19 Jul 2026
Direct dependencies6
Transitive dependenciesNot calculated

README

Version 0.3.0 documentation

aems-pdf-annotator

Schema-driven PDF annotation engine for AEMS — the Assisted Exam Marking System.

What this is

A small, focused library that takes a structured annotation payload (LLM output, rubric verdicts, page-anchored highlights) and draws it onto a PDF using PyMuPDF. It powers the annotated marker PDFs that AEMS returns to instructors.

Key surfaces:

  • PDFAnnotation, BBox, AnnotationBatch — typed models for the annotation payload (Pydantic v2).
  • payload_to_annotations(), feedback_items_to_annotations() — convert AEMS LLM output (the "annotation contract") into typed annotation objects.
  • PDFAnnotator, apply_annotations(), apply_annotation_batch() — open a PDF, draw the annotations, save.
  • Validator + schemas — invariants on coordinates, colours, icons, verdicts.

Installation

pip install aems-pdf-annotator

Or from source:

pip install git+https://github.com/aems-app/aems-pdf-annotator

Requires Python 3.10+.

Minimal example

from aems_pdf_annotator import (
    PDFAnnotation, BBox, AnnotationColor, AnnotationType,
    apply_annotations,
)

annotations = [
    PDFAnnotation(
        page=1,
        bbox=BBox(x=0.10, y=0.20, width=0.40, height=0.04),
        annotation_type=AnnotationType.HIGHLIGHT,
        color=AnnotationColor.GREEN,
        content="Correct identification of the boundary condition.",
        is_verdict=False,
    ),
    PDFAnnotation(
        page=1,
        bbox=BBox(x=0.80, y=0.20, width=0.03, height=0.03),
        annotation_type=AnnotationType.STAR,
        color=AnnotationColor.GREEN,
        content="PASS",
        is_verdict=True,
    ),
]

apply_annotations(
    input_pdf_path="input.pdf",
    output_pdf_path="annotated.pdf",
    annotations=annotations,
)

Coordinates are normalised (0.0–1.0) with (0, 0) at the top-left of the page; the renderer converts to PDF bottom-left internally.

Contract version

The LLM-output payload format follows a versioned contract. Current values are exported as CURRENT_CONTRACT_VERSION and CURRENT_COORDINATE_SPACE. payload_to_annotations() validates the incoming payload's contract version against SUPPORTED_CONTRACT_VERSIONS and raises ContractValidationError on a mismatch.

License

AGPL-3.0-or-later. See LICENSE.

This package wraps PyMuPDF, which is itself licensed under AGPL-3.0. Any program that imports aems_pdf_annotator in-process inherits the AGPL combined-work obligations. If that does not fit your distribution model, commercial PyMuPDF licensing is available from Artifex.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 6

Native requirements
6 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
pydantic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pydantic>=2.0.0runtime
pymupdf
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pymupdf>=1.25.0runtime
mypy
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
mypy>=1.5.0; extra == "dev"runtime
pytest-cov
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest-cov>=4.1.0; extra == "dev"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest>=7.4.0; extra == "dev"runtime
ruff
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
ruff>=0.1.0; extra == "dev"runtime

Distribution files

2 collected
aems_pdf_annotator-0.3.0-py3-none-any.whl

bdist_wheel · 49.05 KB · Python py3

Source file
aems_pdf_annotator-0.3.0.tar.gz

sdist · 297.55 KB · Python source

Source file

Repository

PENDING
aems-app/aems-pdf-annotator

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:24 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:aeca3f76089f71de801ae33b874700def4f1d53e9c513355a75a01d2cb5bc07a

Other collected versions

View all collected versions →