Skip to main content

pdfalto

Python bindings for pdfalto, a PDF to ALTO XML converter built on xpdf and used as the PDF parsing front end of GROBID.

The wheels bundle the compiled pdfalto executable, so there is nothing else to install:

$ pip install pdfalto

Python API

import pdfalto

result = pdfalto.convert("paper.pdf", "paper.xml", outline=True)

print(result.alto)      # paper.xml
print(result.metadata)  # paper_metadata.xml
print(result.outline)   # paper_outline.xml
print(result.data_dir)  # paper.xml_data/  (extracted images and vector graphics)

convert() returns a ConversionResult naming every file that was written. Sidecar attributes are None when the corresponding file was not produced.

To skip the files entirely:

alto_xml = pdfalto.convert_to_string("paper.pdf")

Every pdfalto option is a keyword argument, named after the flag it sets:

pdfalto.convert(
    "paper.pdf", "paper.xml",
    first_page=1, last_page=10,   # -f 1 -l 10
    skip_graphics=True,           # -skipGraphs
    no_line_numbers=True,         # -noLineNumbers
    owner_password="secret",      # -opw secret
)

See help(pdfalto.convert) for the full list. Anything not modelled there can be passed through verbatim:

pdfalto.convert("paper.pdf", extra_args=["-someNewFlag"])
pdfalto.run(["-v"])   # raw call, no exit-status checking

Errors

A failing conversion raises PdfAltoError, carrying the exit status, the command line and the captured stderr:

try:
    pdfalto.convert("broken.pdf")
except pdfalto.PdfAltoError as exc:
    print(exc.returncode, exc.stderr)

Pass check=False to get a ConversionResult with a non-zero returncode instead. Exit status 5 is not an error: the ALTO file was written correctly, but pdfalto had to disable page streaming partway through, so its peak memory was no longer bounded. That case is reported as result.streaming_disabled is True.

Command line

Installing the package puts pdfalto on PATH, with the upstream command line unchanged:

$ pdfalto -outline paper.pdf paper.xml

This is the executable itself, not a Python wrapper around it, so it starts as fast as a hand-built binary (~7 ms rather than ~100 ms) — which matters when something invokes it once per PDF.

It is installed the way any Unix program is, into the environment's bin/ with its resources in share/pdfalto/:

<venv>/bin/pdfalto
<venv>/share/pdfalto/xpdfrc
<venv>/share/pdfalto/languages/

pdfalto finds them relative to itself. PDFALTO_DATA_DIR overrides the lookup if you ever need to point it somewhere else.

Notes on the wheels

  • Wheels are py3-none-<platform>: the package ships an executable rather than an extension module, so one wheel covers every supported Python.

  • Platforms: Linux x86-64 and aarch64, macOS arm64 and x86-64. On any other platform pip falls back to the source distribution, which runs the CMake build and needs a C++17 compiler and CMake ≥ 3.15.

  • The bundled binaries are built without fontconfig, so a conversion does not depend on the fonts installed on the machine and gives the same result everywhere. The binaries published on the pdfalto GitHub releases page do use fontconfig for substituting non-embedded fonts. To get that behaviour:

    $ pip install pdfalto --no-binary pdfalto -C cmake.define.NO_FONTCONFIG=OFF
    
  • PDFALTO_BINARY=/path/to/pdfalto makes the Python API run a different executable, which is handy for testing a local CMake build. Without it the API runs the pdfalto installed in the current environment, falling back to a binary built in a surrounding checkout, so an editable install works too.

License

Same as pdfalto itself; see the LICENSE file in the repository.

Metadata

Release files for pdfalto 0.7.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 pdfalto 0.7.0
File Size Uploaded Provenance Actions
pdfalto-0.7.0.tar.gz 68.9 MB With provenance Details for pdfalto-0.7.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pdfalto 0.7.0
File Actions
pdfalto-0.7.0-py3-none-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64, Linux glibc 2.26+ x86-64 Details for pdfalto-0.7.0-py3-none-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
pdfalto-0.7.0-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details for pdfalto-0.7.0-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
pdfalto-0.7.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details for pdfalto-0.7.0-py3-none-macosx_11_0_x86_64.whl
pdfalto-0.7.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for pdfalto-0.7.0-py3-none-macosx_11_0_arm64.whl

Total release size: 144.3 MB

Release files / pdfalto-0.7.0.tar.gz

Download URL pdfalto-0.7.0.tar.gz
Size 68.9 MB
Tags Source
SHA-256 checksum
How to use checksums
82ac2639243e4945acb589c04e72b21d0bb31760f23564d1aaa2757c2cdf7cdf
BLAKE2b-256 checksum
How to use checksums
ee21c5e09ce4a9bdc651be4c14a48958c70cf9670191850fe969c446236a7042
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Release files / pdfalto-0.7.0-py3-none-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl

Download URL pdfalto-0.7.0-py3-none-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Size 19.0 MB
Tags Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
83de7836f950aa83c1c67ca8c9e6b31e9dafd74522113b4920af6eadfe1013ad
BLAKE2b-256 checksum
How to use checksums
4be11ae539cec05d80643b855eeaac18379e695f90c6bbe6fc253bdba1c9c448
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Release files / pdfalto-0.7.0-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL pdfalto-0.7.0-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 19.0 MB
Tags Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
7928b0a7ee2af910d0cac01e261a3bdfbc396c60a9173af575e332624166cea9
BLAKE2b-256 checksum
How to use checksums
093fa9ab769683c5cab95f440a9aa695e972feba0d5c5f1d8accca4eee68d126
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Release files / pdfalto-0.7.0-py3-none-macosx_11_0_x86_64.whl

Download URL pdfalto-0.7.0-py3-none-macosx_11_0_x86_64.whl
Size 18.6 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
3e9e2201bec5af31b831b23d70b259f63ceb41a53ba458a6c624131de67814bc
BLAKE2b-256 checksum
How to use checksums
f1968f14d6cab728d17b7f17a94f8734ad4b791d808c8210a2a3e2d2045c15f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Release files / pdfalto-0.7.0-py3-none-macosx_11_0_arm64.whl

Download URL pdfalto-0.7.0-py3-none-macosx_11_0_arm64.whl
Size 18.8 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
338d9f43260080c64c32b2090000b268cfacbcfb4030123551ac4c8560658273
BLAKE2b-256 checksum
How to use checksums
42845984692cdd497da175d953616278225bfda54a70d599313ae9705259cbba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Security for pdfalto 0.7.0

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for pdfalto-0.7.0.tar.gz

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 Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.0 This release

5 release files Full provenance

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