Docling simplifies document processing, parsing diverse formats — including advanced PDF understanding — and providing seamless integrations with the gen AI ecosystem.
Go to file
mara004 3eca8b8485
refactor(pypdfium2): just forward input to PdfDocument directly (#17)
PdfDocument() should do accept strings, paths, bytes and byte streams. If not, please file a bug report.

Signed-off-by: mara004 <geisserml@gmail.com>
2024-07-25 08:54:57 +02:00
.github pin docling-ibm-models 1.1.0 with python 3.10 support (#15) 2024-07-18 17:27:48 +02:00
docling refactor(pypdfium2): just forward input to PdfDocument directly (#17) 2024-07-25 08:54:57 +02:00
examples Update convert.py (#3) 2024-07-15 18:02:42 +02:00
test Initial commit 2024-07-15 09:42:42 +02:00
.gitignore ci: Add Github Actions (#4) 2024-07-16 13:05:04 +02:00
.pre-commit-config.yaml fix: add easyocr to main deps for valid extra (#19) 2024-07-24 14:11:26 +02:00
CHANGELOG.md chore: bump version to 1.0.2 [skip ci] 2024-07-24 12:18:21 +00:00
CODE_OF_CONDUCT.md Initial commit 2024-07-15 09:42:42 +02:00
CONTRIBUTING.md Initial commit 2024-07-15 09:42:42 +02:00
Dockerfile doc: More documentation updates (#2) 2024-07-15 14:59:53 +02:00
LICENSE Initial commit 2024-07-15 09:42:42 +02:00
logo.png Initial commit 2024-07-15 09:42:42 +02:00
MAINTAINERS.md Initial commit 2024-07-15 09:42:42 +02:00
poetry.lock fix: add easyocr to main deps for valid extra (#19) 2024-07-24 14:11:26 +02:00
pyproject.toml chore: bump version to 1.0.2 [skip ci] 2024-07-24 12:18:21 +00:00
README.md pin docling-ibm-models 1.1.0 with python 3.10 support (#15) 2024-07-18 17:27:48 +02:00

Docling

Docling

PyPI version Python Poetry Code style: black Imports: isort Pydantic v2 pre-commit License MIT

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.10 / 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.

Adjust pipeline features

Control pipeline options

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)
    ),
)

Control table extraction options

You can control if table structure recognition should map the recognized structure back to PDF cells (default) or use text cells from the structure prediction itself. This can improve output quality if you find that multiple columns in extracted tables are erroneously merged into one.

pipeline_options = PipelineOptions(do_table_structure=True)
pipeline_options.table_structure_options.do_cell_matching = False  # uses text cells predicted from table structure model

doc_converter = DocumentConverter(
    artifacts_path=artifacts_path,
    pipeline_options=pipeline_options,
)

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.