Read any PDF and preserve its document structure (headings, tables, lists, key-value pairs, checkboxes, reading order, bounding boxes) as JSON. Powered by Docling.
Project description
knowledge-extractor-ai
Read any PDF and preserve its document structure — headings, paragraphs, tables, lists, key-value pairs, checkboxes, reading order and bounding boxes — as clean JSON, instead of flattening it to plain text.
Powered by Docling for layout analysis.
Install
pip install knowledge-extractor-ai
Usage
Python
from knowledgeextract.pdf import extract_pdf
doc = extract_pdf("myfile.pdf")
doc.to_json("result.json") # write structured JSON
print(doc.markdown) # Markdown view
Command line
pdf-extract extract myfile.pdf -o result.json -m result.md
The first run downloads/loads Docling's layout models and may take a few minutes; subsequent runs are fast.
What gets extracted
| Field | Notes |
|---|---|
| Headings | with level |
| Paragraphs | body text blocks |
| Tables | rows + dimensions |
| Lists | items grouped, ordered/unordered |
| Checkboxes | checked state + label |
| Key-value pairs | label/value regions |
| Images | reference + bounding box (no bytes) |
| Bounding boxes | on every element (PDF points, top-left origin) |
| Reading order | document-wide ordering |
| Markdown | rendered view of the whole document |
Output shape
{
"metadata": { "filename": "myfile.pdf", "page_count": 1, "engine": "docling" },
"pages": [
{
"page_number": 1,
"width": 612.0,
"height": 792.0,
"elements": [
{ "type": "heading", "order": 0, "page_number": 1, "level": 1,
"bbox": { "x0": 78.0, "y0": 111.0, "x1": 178.0, "y1": 127.7 },
"text": "1. Overview" }
]
}
],
"reading_order": [0, 1, 2],
"markdown": "## 1. Overview\n..."
}
Project layout
Each file format is a self-contained subpackage. PDF ships today; Word, Excel and others plug in alongside it.
knowledgeextract/
└── pdf/
├── converter.py # Docling wrapper
├── normalize.py # Docling -> schema
├── models.py # JSON schema (Pydantic)
└── cli.py # pdf-extract command
License
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file knowledge_extractor_ai-0.1.0.tar.gz.
File metadata
- Download URL: knowledge_extractor_ai-0.1.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39bb4fbbe61213bbc4e849c7f409880525224ea9f3f0e5a8b7168729bded54cb
|
|
| MD5 |
2846b7bb38c55d5bc929f00de2f96442
|
|
| BLAKE2b-256 |
76d156fa48f2d505868a22700b2259e2c3aa6a5fb1f22fc03b67be6d651659a8
|
File details
Details for the file knowledge_extractor_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: knowledge_extractor_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1e0fc2586a05078bddfbdd07b7f6a91d97e47810a38c4d330cba5b3a9c89257
|
|
| MD5 |
08572da1a74778282d5f6c222a0527f8
|
|
| BLAKE2b-256 |
b53ee2eb67fc8e96c4978c9e11c6f5644a61afbcf93c46a593fb33d140c0c033
|