Skip to main content

pdf-textlayer (Python)

Add an invisible, searchable text layer to a PDF from OCR JSON. The writer is Rust; this package is a typed wrapper around it with no runtime dependencies. Pages without OCR text are left as in the input: native text, embedded fonts, and annotations are preserved.

Source, benchmarks, and the Node.js and Rust packages: GitHub.

Installation

Python 3.11+.

pip install pdf-textlayer
# or
uv add pdf-textlayer

This installs the pdf_textlayer package and the pdf-textlayer command.

CLI

# 1. Produce OCR JSON. --extract-text-metadata adds per-item rotation.
lit parse input.pdf --format json --extract-text-metadata -o parsed.json

# 2. Build the searchable PDF
pdf-textlayer input.pdf parsed.json output.pdf \
    --from liteparse \       # JSON format (default: liteparse)
    --min-confidence 0.5 \   # drop low-confidence OCR items
    --font tiro              # size the text with Times widths (helv, tiro, cour)

Library

from pdf_textlayer import Options, make_searchable_pdf

stats = make_searchable_pdf(
    "input.pdf",
    "parsed.json",              # path, or the already-loaded dict
    "output.pdf",
    adapter="liteparse",        # default
    options=Options(min_confidence=0.5, font="helv"),
)
print(stats)
# {'pages': 19, 'ocr_pages': [1, 2, ..., 19], 'items_drawn': 7643}

OCR results from any other source go in as ParsedPage objects:

from pdf_textlayer import ParsedPage, TextBox, write_textlayer

pages = [
    ParsedPage(
        page_number=1,
        boxes=[
            TextBox(text="Hello", x=72.0, y=108.0, width=46.0, height=12.0, confidence=0.98),
            TextBox(text="world", x=124.0, y=108.0, width=48.0, height=12.0, confidence=0.97),
        ],
    ),
]
write_textlayer("input.pdf", pages, "output.pdf")
Function Does
make_searchable_pdf(input_pdf, source, output_pdf, *, adapter, options) Reads OCR JSON (path or dict) with an adapter and writes the PDF. source may also be a list of ParsedPage.
write_textlayer(input_pdf, pages, output_pdf, *, options) Writes the PDF from ParsedPage objects.
add_textlayer(pdf_bytes, pages, *, options) Same, in memory. Returns (pdf_bytes, stats).
load_pages(source, *, adapter) Returns the ParsedPage objects an adapter reads from OCR JSON, to inspect or edit before writing.

All of them run in Rust with the GIL released. They raise FileNotFoundError for a missing input, PdfError for a file that is not a readable PDF or is encrypted, and ValueError for an unknown adapter or font, or invalid JSON.

Coordinates have their origin at the top-left of the displayed page, x right, y down, in PDF points. (x, y) is the top-left corner of the box. TextBox.rotation is degrees counter-clockwise (0, 90, 180, 270); other values snap to a right angle.

Adapters

Name Source Notes
liteparse liteparse lit parse --format json pages[].text_items[] with font_name == "OCR". Reads rotation when present (--extract-text-metadata). textItems / fontName are still accepted.

License

MIT.

Metadata

Release files for pdf-textlayer 0.3.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 pdf-textlayer 0.3.0
File Size Uploaded Provenance Actions
pdf_textlayer-0.3.0.tar.gz 57.6 kB With provenance Details for pdf_textlayer-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pdf-textlayer 0.3.0
File Actions
pdf_textlayer-0.3.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for pdf_textlayer-0.3.0-cp311-abi3-win_arm64.whl
pdf_textlayer-0.3.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for pdf_textlayer-0.3.0-cp311-abi3-win_amd64.whl
pdf_textlayer-0.3.0-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details for pdf_textlayer-0.3.0-cp311-abi3-musllinux_1_2_x86_64.whl
pdf_textlayer-0.3.0-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details for pdf_textlayer-0.3.0-cp311-abi3-musllinux_1_2_aarch64.whl
pdf_textlayer-0.3.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for pdf_textlayer-0.3.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
pdf_textlayer-0.3.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for pdf_textlayer-0.3.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
pdf_textlayer-0.3.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for pdf_textlayer-0.3.0-cp311-abi3-macosx_11_0_arm64.whl
pdf_textlayer-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for pdf_textlayer-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 8.7 MB

Release files / pdf_textlayer-0.3.0.tar.gz

Download URL pdf_textlayer-0.3.0.tar.gz
Size 57.6 kB
Tags Source
SHA-256 checksum
How to use checksums
432e23100b908e956a75f107e64eb0ba2d778bcd9f8fbc3dc5e52aba274980e4
BLAKE2b-256 checksum
How to use checksums
34ed1c5c734ac00b8824926e57ecb0f9355c4e01bff4cad60c2d41c8e9013be6
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 11, 2026.

Transparency log

Release files / pdf_textlayer-0.3.0-cp311-abi3-win_arm64.whl

Download URL pdf_textlayer-0.3.0-cp311-abi3-win_arm64.whl
Size 965.1 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
7d491475893d8b5fa18c9c63d79bf3d432332c142fd313f39cea7aa2ca3fb07c
BLAKE2b-256 checksum
How to use checksums
60d42bd7fbc0d82f893451e9f132685f6ae05b23974fc96e2e822bddce98abd2
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 11, 2026.

Transparency log

Release files / pdf_textlayer-0.3.0-cp311-abi3-win_amd64.whl

Download URL pdf_textlayer-0.3.0-cp311-abi3-win_amd64.whl
Size 1.0 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2a8a3c2a2765e05f4c72300941ec29909e6f464508d4d0ef61349b9ec23817d3
BLAKE2b-256 checksum
How to use checksums
edaf26e05b0341f1411c409e4d3b53e0f06f7bbc69eacc782eef2de4bb3bc98f
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 11, 2026.

Transparency log

Release files / pdf_textlayer-0.3.0-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL pdf_textlayer-0.3.0-cp311-abi3-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
931afb2fa5406a5e37ba556352cc3eb3140e101607cc883098aa4def4afd1683
BLAKE2b-256 checksum
How to use checksums
ef255cdbcaa079f3efe8f531190a6116adf22c3567ba18c3416495609a9404f6
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 11, 2026.

Transparency log

Release files / pdf_textlayer-0.3.0-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL pdf_textlayer-0.3.0-cp311-abi3-musllinux_1_2_aarch64.whl
Size 1.2 MB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
33ca2641b2019601bbe98f7c36f97d46e2db4cf24a99dc5f97ef8a8e21c1a32b
BLAKE2b-256 checksum
How to use checksums
dde822641cac4428662f2efe582519979b313e8b0505dba54a4b86ab6e62da92
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 11, 2026.

Transparency log

Release files / pdf_textlayer-0.3.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pdf_textlayer-0.3.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.1 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8a73278bf178587d90a76d6aa0a88d4b3af45cfa22a27d8b382678f64cf7aa65
BLAKE2b-256 checksum
How to use checksums
f2fc1dc14423f7e795c9b259133ca6b78ab64bd2df040367cf78ec39b2dc2469
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 11, 2026.

Transparency log

Release files / pdf_textlayer-0.3.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pdf_textlayer-0.3.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.0 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
40334cc5fd177ffafd2f371fdc74d57b0fd98d42a6508326fe55b40d0ee9bb99
BLAKE2b-256 checksum
How to use checksums
9e2d5f413637241f4287dfef7dda9ae757d72015f740bde51075440827a22931
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 11, 2026.

Transparency log

Release files / pdf_textlayer-0.3.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL pdf_textlayer-0.3.0-cp311-abi3-macosx_11_0_arm64.whl
Size 951.1 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0148ca66505844ab8573c03cbcc49ada69084363dc025c9cedeadcde2abf65b6
BLAKE2b-256 checksum
How to use checksums
812665a49c70e3b6791ed1152730d7f02ea0d8e82596fca60c8c9e462811b74c
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 11, 2026.

Transparency log

Release files / pdf_textlayer-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL pdf_textlayer-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 1.0 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
0d887e2f5795cb27a23d8b67167599eaa205db81e44d450c664c7aa191a5214d
BLAKE2b-256 checksum
How to use checksums
960912cec2c3fd9555605c5e4224717fd4cea1b27a4f26722aba3ac205fa0ca9
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 11, 2026.

Transparency log

Security for pdf-textlayer 0.3.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 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for pdf_textlayer-0.3.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 11, 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.

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