Skip to main content

Convert born-digital PDF text blocks to BigQuery-ready JSONL.

Project description

pdf-jsonl-smith

pdf-jsonl-smith is a thin, boring wrapper around PyMuPDF for converting text-based PDF files into BigQuery-ready newline-delimited JSON.

It is intended for upstream ELT pipelines that need flat text-unit records, not document understanding.

Install

uv pip install -e ".[dev]"

CLI

pdf2jsonl input.pdf -o text_units.jsonl

Optional metadata:

pdf2jsonl input.pdf \
  --output text_units.jsonl \
  --source-uri gs://bucket/input.pdf \
  --schema-version 0.1

By default, the CLI prints a short completion summary to stdout:

Wrote 42 records to text_units.jsonl from input.pdf.

Use --quiet to suppress the summary.

Python API

from pdf_jsonl_smith import extract_pdf_to_jsonl

count = extract_pdf_to_jsonl(
    input_path="input.pdf",
    output_path="text_units.jsonl",
    source_uri="gs://bucket/input.pdf",
)

The function returns the number of JSONL records written.

Output

The output is UTF-8 JSONL: one standalone JSON object per text unit. Records are flat and BigQuery-friendly.

For v0.1, extraction starts from PyMuPDF text blocks. Adjacent blocks on the same page may be merged when their geometry looks like wrapped lines from the same paragraph. This is intentionally conservative and does not try to infer document semantics.

Fields:

schema_version STRING
doc_id STRING
source_uri STRING
filename STRING
page_number INT64
unit_type STRING
unit_index INT64
text STRING
bbox_x0 FLOAT64
bbox_y0 FLOAT64
bbox_x1 FLOAT64
bbox_y1 FLOAT64
char_count INT64
word_count INT64
extractor STRING
extracted_at TIMESTAMP
warning STRING

Supported

  • Born-digital PDFs.
  • PyMuPDF block-based text extraction.
  • Conservative same-page wrapped-line merging.
  • UTF-8 JSONL output.
  • BigQuery-friendly flat records.
  • Images ignored.

Not Supported

  • Scanned PDFs / OCR.
  • Table reconstruction.
  • Perfect reading order.
  • Cross-page paragraph reconstruction.
  • Semantic heading detection.
  • Forms.
  • Image text.

Development

uv sync --dev
uv run pytest
uv run ruff check
uv run sphinx-build -b html docs/source docs/build/html
uv build

Project Infrastructure

This project is maintained as a uv-based Python package.

Releases use Python Semantic Release with zero-version releases enabled for the initial 0.x series. The GitHub Actions release workflow runs on main, creates releases from conventional commits, builds distributions with uv, and publishes to PyPI using trusted publishing.

Documentation sources live in docs/source, build output goes under docs/build, and the site uses Sphinx with the Furo theme. It is intended to be built by Read the Docs through the RTD GitHub App integration.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_jsonl_smith-0.1.0.tar.gz (66.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf_jsonl_smith-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pdf_jsonl_smith-0.1.0.tar.gz.

File metadata

  • Download URL: pdf_jsonl_smith-0.1.0.tar.gz
  • Upload date:
  • Size: 66.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pdf_jsonl_smith-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f682e285a0b26c12bc1e74f8d8fbcf96ef35f39835118492de2f3ad041b8d191
MD5 ba44b874c2c3630043f9e3c0484a8921
BLAKE2b-256 40199554a0edf436089958d4ce36b4ad4d38e5b7b4dc546170a0115a6e5e50f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdf_jsonl_smith-0.1.0.tar.gz:

Publisher: publish.yml on yeiichi/pdf-jsonl-smith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pdf_jsonl_smith-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_jsonl_smith-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54745526f8f30bf23d4e02bd0da85b4eddf2efea0ec8a5a0f22ccec709114e36
MD5 23b08601b1ed6191fd3e9ce0337055d7
BLAKE2b-256 152debf848046d72a1181bd922ad1dc8b0cec38de3dbf546215d684b32728e61

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdf_jsonl_smith-0.1.0-py3-none-any.whl:

Publisher: publish.yml on yeiichi/pdf-jsonl-smith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page