pdf-jsonl-smith
pdf-jsonl-smith converts PDF-derived text into compact BigQuery-ready
newline-delimited JSON.
The local app is a thin, boring wrapper around PyMuPDF for born-digital PDFs.
The docai app runs Google Document AI Form Parser, but still emits compact
purpose-built records instead of full Document AI payloads.
Install
uv pip install -e ".[dev]"
For the Google Document AI app:
uv pip install -e ".[dev,gcp]"
CLI
pdf-jsonl-smith local input.pdf -o text_units.jsonl
Optional metadata:
pdf-jsonl-smith local 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.
The older pdf2jsonl command remains available as a compatibility alias for
the local PyMuPDF extractor:
pdf2jsonl input.pdf -o text_units.jsonl
The docai app uploads a local PDF to Cloud Storage, runs Google Document AI,
and writes compact JSONL records:
pdf-jsonl-smith docai input.pdf \
--output compact.jsonl \
--project my-project \
--location us \
--processor-id PROCESSOR_ID \
--staging-uri gs://bucket/pdf-jsonl-smith/input/
By default, docai emits compact text, key-values, tables, and lists
records. Use --include to narrow the output:
pdf-jsonl-smith docai input.pdf \
--output compact.jsonl \
--project my-project \
--location us \
--processor-id PROCESSOR_ID \
--staging-uri gs://bucket/pdf-jsonl-smith/input/ \
--include text,key-values
Use --jsonl-gcs-uri to upload the compact JSONL output after writing it
locally.
For a beginner-friendly explanation of Document AI, buckets, and authentication, see the Document AI page in the published docs.
The bq app is reserved for the BigQuery workflow:
pdf-jsonl-smith bq
The docai app policy is to extract from rich Google Document AI payloads, but
emit only compact, purpose-built records. Full Document AI payloads are not part
of the final JSONL output.
Useful jq checks:
jq -r '.unit_type' compact.jsonl | sort | uniq -c
jq -r 'select(.unit_type=="text") | .text' compact.jsonl
jq -r 'select(.unit_type=="key_value") | [.key, .value, .confidence] | @tsv' \
compact.jsonl
Because the output is one unified JSONL stream, filter by unit_type when you
want only main text, form key-value pairs, table cells, or list items.
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 the local extractor, 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.
- Google Document AI Form Parser compact output.
- UTF-8 JSONL output.
- BigQuery-friendly flat records.
- One unified JSONL stream with
unit_typefilters.
Not Supported
For the local extractor:
- Scanned PDFs / OCR.
- Forms.
- Image text.
For all extractors:
- Full Document AI payload mirroring.
- Perfect reading order.
- Cross-page paragraph reconstruction.
- Semantic heading detection.
- Lossless table reconstruction.
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
Metadata
Release files for pdf-jsonl-smith 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pdf_jsonl_smith-0.2.0.tar.gz | 99.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pdf_jsonl_smith-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 112.7 kB
Release files / pdf_jsonl_smith-0.2.0.tar.gz
| Download URL | pdf_jsonl_smith-0.2.0.tar.gz |
|---|---|
| Size | 99.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8378ecab2b559a57e4e944e01142419727655ff7d0dcbd386b83e3ce39db111c
|
|
BLAKE2b-256 checksum How to use checksums |
1cbdff5451223c5ef464a7099395fd9101be316885ead466880c0164586ba580
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 12, 2026.
Transparency logRelease files / pdf_jsonl_smith-0.2.0-py3-none-any.whl
| Download URL | pdf_jsonl_smith-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6d626536ed56a816b666e2aa8e9b7dd6adcf4c25d15cbd27b0eba27deb8a740
|
|
BLAKE2b-256 checksum How to use checksums |
29cd330ebeef70abaecd237d026bb905924f20add732a98ab35147bce5f90c42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 12, 2026.
Transparency logSecurity for pdf-jsonl-smith 0.2.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 2 files in this release have been uploaded with provenance metadata.
Attestation for pdf_jsonl_smith-0.2.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 Jul 12, 2026.
Transparency logA 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.