Skip to main content

pygexml

A minimal Python wrapper around the PAGE-XML format for OCR output. Can also import ALTO-XML.

pygexml checks, tests and docs pypi release API docs online

Installation

pip install pygexml

Requires Python 3.12+.

Usage

from pygexml import Page

page = Page.from_xml_file("docs/xml_file.xml")

for line in page.all_text():
    print(line)

All dataclasses are serializable with to_dict/from_dict and to_json/from_json via dataclasses-json.

Data model

Class Import from
Page pygexml
Page, TextRegion, TextLine, Coords pygexml.page
Point, Box, Polygon pygexml.geometry

Page, TextRegion and TextLine each expose all_text() and all_words() iterators. On Page, these respect the PAGE-XML reading order if present. Lookups by ID are available via lookup_region() and lookup_textline(). The reading order is also accessible directly via regions_ordered().

Refer to the online API docs for details.

Hypothesis strategies

The pygexml.strategies module provides Hypothesis strategies for all pygexml types, ready to use in property-based tests - including downstream projects:

from hypothesis import given
from pygexml.strategies import st_pages

@given(st_pages())
def test_my_page_processing(page):
    assert process(page) is not None

Refer to the pygexml.strategies API docs for details.

Development

pip install ".[dev,test,docs]"

black pygexml test          # format
mypy pygexml test           # type check
pyright pygexml test        # type check
pytest -v                   # tests
pdoc -o .api_docs ./pygexml # API docs

CI runs on Python 3.12, 3.13 and 3.14. API documentation is published to GitHub Pages on every push to main.

Contributing

Bug reports, feature requests and pull requests are welcome. Feel free to open draft pull requests early to invite discussion and collaboration.

Please note that this project has a Code of Conduct.

Copyright and License

Copyright (c) 2026 Mirko Westermeier, Katharina Dietz (SCDH, University of Münster)

Released under the MIT License.

Release files for pygexml 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygexml 0.4.0
File Size Uploaded
pygexml-0.4.0.tar.gz 18.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygexml 0.4.0
File Interpreter ABI Platform
pygexml-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.7 kB

Release files / pygexml-0.4.0.tar.gz

Download URL pygexml-0.4.0.tar.gz
Size 18.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cf8ca7976ffdd54dfc54da66bc60fec3eb0b7aa6c7057198b98c8ffd6641db56
BLAKE2b-256 checksum
How to use checksums
ec0294d4fab1c56d3aed37e989d3b5195a261175d5555256414346c33f7f7ed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

Release files / pygexml-0.4.0-py3-none-any.whl

Download URL pygexml-0.4.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e88e421b0bd5c5491836df42fbafce1fb52432c3509046f86e7e25ca11b1947
BLAKE2b-256 checksum
How to use checksums
2caaece281bdb63fbda598205fda8b9bb53024f42904f5dbc8c9a5f6aa0ab3b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page