Docling PDF conversion package
Project description
Docling
Docling bundles PDF document conversion to JSON and Markdown in an easy, self-contained package.
Features
- ⚡ Converts any PDF document to JSON or Markdown format, stable and lightning fast
- 📑 Understands detailed page layout, reading order and recovers table structures
- 📝 Extracts metadata from the document, such as title, authors, references and language
- 🔍 Optionally applies OCR (use with scanned PDFs)
Installation
To use Docling, simply install docling
from your package manager, e.g. pip:
pip install docling
[!NOTE]
Works on macOS and Linux environments. Windows platforms are currently not tested.
Development setup
To develop for Docling, you need Python 3.11 / 3.12 and Poetry. You can then install from your local clone's root dir:
poetry install
Usage
For basic usage, see the convert.py example module. Run with:
python examples/convert.py
The output of the above command will be written to ./scratch
.
Enable or disable pipeline features
You can control if table structure recognition or OCR should be performed by arguments passed to DocumentConverter
:
doc_converter = DocumentConverter(
artifacts_path=artifacts_path,
pipeline_options=PipelineOptions(
do_table_structure=False, # controls if table structure is recovered
do_ocr=True, # controls if OCR is applied (ignores programmatic content)
),
)
Impose limits on the document size
You can limit the file size and number of pages which should be allowed to process per document:
conv_input = DocumentConversionInput.from_paths(
paths=[Path("./test/data/2206.01062.pdf")],
limits=DocumentLimits(max_num_pages=100, max_file_size=20971520)
)
Convert from binary PDF streams
You can convert PDFs from a binary stream instead of from the filesystem as follows:
buf = BytesIO(your_binary_stream)
docs = [DocumentStream(filename="my_doc.pdf", stream=buf)]
conv_input = DocumentConversionInput.from_streams(docs)
converted_docs = doc_converter.convert(conv_input)
Limit resource usage
You can limit the CPU threads used by Docling by setting the environment variable OMP_NUM_THREADS
accordingly. The default setting is using 4 CPU threads.
Contributing
Please read Contributing to Docling for details.
References
If you use Docling in your projects, please consider citing the following:
@software{Docling,
author = {Deep Search Team},
month = {7},
title = {{Docling}},
url = {https://github.com/DS4SD/docling},
version = {main},
year = {2024}
}
License
The Docling codebase is under MIT license. For individual model usage, please refer to the model licenses found in the original packages.
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
File details
Details for the file docling-0.3.1.tar.gz
.
File metadata
- Download URL: docling-0.3.1.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6fea0a41a3570f265b1dd84a09774d203ec6b83fc7b0f79de303de6a57050ba |
|
MD5 | f11d117d99c9775ed3e90b0d296ab2f9 |
|
BLAKE2b-256 | fc9908b2b5be7886116bc76234b759d716eaba84683c55626dfea2ababa5baf3 |
Provenance
File details
Details for the file docling-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: docling-0.3.1-py3-none-any.whl
- Upload date:
- Size: 32.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fdc6e679e5e8a4d1b901d1f9a11e878f6d8943d44e22da271bd47378b300cf1 |
|
MD5 | f9bf399adb80e873e8477532efc537d9 |
|
BLAKE2b-256 | 68caa78044cc90e2abe13a7ad826947e1e9ba684dfb9050f57ff4c28f3990430 |