Simple package to extract text with coordinates from programmatic PDFs
Project description
Docling Parse
Simple package to extract text, paths and bitmap images with coordinates from programmatic PDFs. This package is used in the Docling PDF conversion.
Version | Original | Word-level | Snippet-level | Performance |
---|---|---|---|---|
V1 | Not Supported | ~0.250 page/sec | ||
V2 | ~0.050 page/sec [~5-10X faster than v1] |
Quick start
Install the package from Pypi
pip install docling-parse
Convert a PDF (look in the visualise.py for a more detailed information)
from docling_parse.docling_parse import pdf_parser_v2
# Do this only once to load fonts (avoid initialising it many times)
parser = pdf_parser_v2()
# parser.set_loglevel(1) # 1=error, 2=warning, 3=success, 4=info
doc_file = "my-doc.pdf" # filename
doc_key = f"key={pdf_doc}" # unique document key (eg hash, UUID, etc)
# Load the document from file using filename doc_file. This only loads
# the QPDF document, but no extracted data
success = parser.load_document(doc_key, doc_file)
# Open the file in binary mode and read its contents
# with open(pdf_doc, "rb") as file:
# file_content = file.read()
# Create a BytesIO object and write the file contents to it
# bytes_io = io.BytesIO(file_content)
# success = parser.load_document_from_bytesio(doc_key, bytes_io)
# Parse the entire document in one go, easier, but could require
# a lot (more) memory as parsing page-by-page
# json_doc = parser.parse_pdf_from_key(doc_key)
# Get number of pages
num_pages = parser.number_of_pages(doc_key)
# Parse page by page to minimize memory footprint
for page in range(0, num_pages):
# Internal memory for page is auto-deleted after this call.
# No need to unload a specifc page
json_doc = parser.parse_pdf_from_key_on_page(doc_key, page)
if "pages" not in json_doc: # page could not get parsed
continue
# parsed page is the first one!
json_page = json_doc["pages"][0]
# <Insert your own code>
# Unload the (QPDF) document and buffers
parser.unload_document(doc_key)
# Unloads everything at once
# parser.unload_documents()
Use the CLI
$ docling-parse -h
usage: docling-parse [-h] -p PDF
Process a PDF file.
options:
-h, --help show this help message and exit
-p PDF, --pdf PDF Path to the PDF file
Performance Benchmarks
We ran the v1 and v2 parser on DocLayNet. We found the following overall behavior
Development
CXX
To build the parse, simply run the following command in the root folder,
rm -rf build; cmake -B ./build; cd build; make
You can run the parser from your build folder. Example from parse_v1,
% ./parse_v1.exe -h
A program to process PDF files or configuration files
Usage:
PDFProcessor [OPTION...]
-i, --input arg Input PDF file
-c, --config arg Config file
--create-config arg Create config file
-o, --output arg Output file
-l, --loglevel arg loglevel [error;warning;success;info]
-h, --help Print usage
Example from parse_v2,
% ./parse_v2.exe -h
program to process PDF files or configuration files
Usage:
PDFProcessor [OPTION...]
-i, --input arg Input PDF file
-c, --config arg Config file
--create-config arg Create config file
-p, --page arg Pages to process (default: -1 for all) (default:
-1)
-o, --output arg Output file
-l, --loglevel arg loglevel [error;warning;success;info]
-h, --help Print usage
If you dont have an input file, then a template input file will be printed on the terminal.
Python
To build the package, simply run (make sure poetry is installed),
poetry build
To test the package, run:
poetry run pytest ./tests -v -s
Contributing
Please read Contributing to Docling Parse for details.
References
If you use Docling in your projects, please consider citing the following:
@techreport{Docling,
author = {Deep Search Team},
month = {8},
title = {Docling Technical Report},
url = {https://arxiv.org/abs/2408.09869},
eprint = {2408.09869},
doi = {10.48550/arXiv.2408.09869},
version = {1.0.0},
year = {2024}
}
License
The Docling Parse 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 Distributions
Hashes for docling_parse-2.0.3-pp310-pypy310_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5ff8a4b4fdc1ce2b77236b00c6e65c035e195933b91c71005c2fe510a6da917 |
|
MD5 | d5b410862b7f5a1b65d8ed4141470e11 |
|
BLAKE2b-256 | 6606d94586930b5d4ab78f208c540f29de268d09ca4a7b886a4b3ca8caea8a5f |
Hashes for docling_parse-2.0.3-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e81d11cb296d7ef4525515c22bc3ae9cbe254f7233f5ba8a083f9b6e048d23c |
|
MD5 | c4705bafd1b815d8cf1eca1ebc9c07b7 |
|
BLAKE2b-256 | 732dd62529627923d72c94bdf289a03ea1e9b3e1af480713296deb2946917355 |
Hashes for docling_parse-2.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33127e2bd64cd7b59af46c3234a0d9b5c8f84c076960870932c17b1ffb799fe9 |
|
MD5 | 4ff32e07591d56e6b935bf70e9376233 |
|
BLAKE2b-256 | 778489caf6ae39b78e6d261d6962596e51c4d9e93270bc5fa06ac811d0256301 |
Hashes for docling_parse-2.0.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4403b9ba8a6d7d9d34df0ec7bf12e8613378b99d63dae2e725cccdb600edb278 |
|
MD5 | 924f873f85112d75cde2a1f46aed9bb5 |
|
BLAKE2b-256 | 02fcf1143e9cd2b050f47924ab664bbb62091109de6cd648a59ed06af0005558 |
Hashes for docling_parse-2.0.3-cp313-cp313-macosx_14_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 052c7ea7781241cd3215243932cf4d3a18858ab2ce47271d3e9d2a60214411bb |
|
MD5 | 14c4944e71f57f51ed6c31c6edc4f749 |
|
BLAKE2b-256 | 547da6f63a4d7011a25774b6dfcf4691fd53d42b3c460981bae589585bd3a87e |
Hashes for docling_parse-2.0.3-cp313-cp313-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d58a08dab1607da95630f1f3625557d178e1af2f88e97bf5c1d7ff0a705349a2 |
|
MD5 | 046fd4241459c41d99597df381d5a0cb |
|
BLAKE2b-256 | dd6179aa4c8b5b63316588356c018cdcde800a2d9665d61e89e7557669d4e7ea |
Hashes for docling_parse-2.0.3-cp313-cp313-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 659db85825dbc6c7f25ee45163c5f4a847b296b05e0d0956789f079387fdb65f |
|
MD5 | af850b21353c5bb73c37d8cd9bd9e773 |
|
BLAKE2b-256 | 56c0785179947bbd74fa32e424bdaf28948ee794145623c919779f716bc6a34b |
Hashes for docling_parse-2.0.3-cp313-cp313-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc2f5412f559d78ef5eb364875533e6210e9324f53a9494b7c3b897ceeb3cfed |
|
MD5 | 07ee115f6fda9ef685d5ce6c49274247 |
|
BLAKE2b-256 | 79768009856ab0a6fb638ac7a04531416f99c227916d86e0235250c4a9d81070 |
Hashes for docling_parse-2.0.3-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f9dfbb8688b4240ed432403c321b75a102662129302409c8253234c5063d169 |
|
MD5 | fe50ba98bc12a41a5ecd4157995e572d |
|
BLAKE2b-256 | c7f6d8e47b80d8dd20bcf9a5547fc9b32df05efdac1a9f31aa763bd118cfd08c |
Hashes for docling_parse-2.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5e513d68880b1d7a2a76d7d0d85342b1a04d794e40d35215cd69185b891c81d |
|
MD5 | 7a97e9abdfa21d432806f32a86a042b5 |
|
BLAKE2b-256 | 59a673c4341b1d3b093651b17050b40bb3e8d78d870c6b2431011106da8ef7ad |
Hashes for docling_parse-2.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0b319497f366f1c8257cec9ddfeb1fa237ea2ff5b60c230de8df3485550621b |
|
MD5 | 01f250af31c1c3b4fac099a6d25abae2 |
|
BLAKE2b-256 | 1ebe7f9c8086bf1abc83ff249727a779f238358c91bee7f05460bcf3689a3286 |
Hashes for docling_parse-2.0.3-cp312-cp312-macosx_14_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c028c9d3f3b586b43c8258dec3f6ed84770a8d1bf042e6c8c4058d060acf8637 |
|
MD5 | 81e5dae5db596c03b870487e58a01023 |
|
BLAKE2b-256 | c461b3ce5977dd0d4e34aaed7ef8cc0fc60b543433dcdacad61e6b82e663a84b |
Hashes for docling_parse-2.0.3-cp312-cp312-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 248f9cf6a3380f1405e9d2b94b1d3759edaede1baaf27ad5957f1860eade56ef |
|
MD5 | 33068f61c5c2e20d15ec9e1f488c7ad3 |
|
BLAKE2b-256 | 1670c8fca04c6f579e73f94ac8bc62baf0cce98b9b2149f5f0f1d02bcc68166a |
Hashes for docling_parse-2.0.3-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55febc86776cdf0eea169f4d572d8edb404ed77bd6a02969739fe7562db9ba14 |
|
MD5 | a920ec54c86341088ef0d44b8d41d9fd |
|
BLAKE2b-256 | 176c1188519104013ae99126512128f43f7b8c6386ba756064d14d7d992b4055 |
Hashes for docling_parse-2.0.3-cp312-cp312-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6576e6f21379b6a673ca1b6827c64d15d8504ec459925f5176e09128eca08ae9 |
|
MD5 | d22f3116d9bb55e4242926d27e5d8eb3 |
|
BLAKE2b-256 | 50407413a037f761e0070a2730e74881278184e1a669bf9ec3dc059867914172 |
Hashes for docling_parse-2.0.3-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b5025c46888ebb41cc2734f3c0289bc272923ca2b5ef1aa1d8abe49f95643d1 |
|
MD5 | bf81da68e8df58c324287e7d32b3ae2d |
|
BLAKE2b-256 | 5dba6c8860462002a7b14c06d64c4049c04fd2dd21c6e58c8ea195e3e46c76ef |
Hashes for docling_parse-2.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1af9a459b7827330a509b46f392e4abcbb81197b18b370ca21570d3dab12dfb |
|
MD5 | 57a96f730e5429324a33901e46aad721 |
|
BLAKE2b-256 | c09c6804b55d48609305853ff7db8d87ceb99e93203e2a2b277224c3a860f624 |
Hashes for docling_parse-2.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22c6c5e567153d905853158b055ac93f3592f1de50c0c94563e8a065aaa8f3b8 |
|
MD5 | e734eb617b83bca8ae6df5b92dde2e3d |
|
BLAKE2b-256 | 5a5c33248aa3c8e7ced1a020033be26d0405647ecddf9dd420b6e7a526f9b3fa |
Hashes for docling_parse-2.0.3-cp311-cp311-macosx_14_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59df67516a2f760576e4c7ceb7c352b461ae95df5e69b465bbc5277963ad4896 |
|
MD5 | 81b26d5f600ec7eb34a7f2b2268f9ad9 |
|
BLAKE2b-256 | 1c01871f3a839e04e36744e74c0991cd93f812c020d116327741eee4e693862f |
Hashes for docling_parse-2.0.3-cp311-cp311-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d2e09967ece6ef33979750532fba5078e22c64014bf8b5a0b176cb92b0973f1 |
|
MD5 | 88941acc1fb9f465307ea5bad563c36c |
|
BLAKE2b-256 | 3985b5c78735c3d865daaaeee0c31ddf4678c6ba31d35394dc2f160d57679fe3 |
Hashes for docling_parse-2.0.3-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a76fd0765c1946f5c568bc8bce56f26ff2bfb409194158c71f1b4ab9e01dac48 |
|
MD5 | 82a46caeb53ec257e861bfc49b032940 |
|
BLAKE2b-256 | bc043e36e5ec014c9151824ba82d0b17fb700474dcf55700e5d2c5224e2c6cc6 |
Hashes for docling_parse-2.0.3-cp311-cp311-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04420782b1a66927cdb739f8f5cf5db1cb7c33fb5af40181a797e2eb720b983f |
|
MD5 | d0ef76f70d08ea67485b942f81e89fbe |
|
BLAKE2b-256 | d6b09b3afb4caf4f09afb0c541219d369e696b84eb55ae31f4cd174bcc28cd50 |
Hashes for docling_parse-2.0.3-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed0a05314d14ed17e8a58ea27931557f2271006f2bb6baef696d30d74d5c6b1f |
|
MD5 | 338cd1155ec98f995f45374ba2cd3de5 |
|
BLAKE2b-256 | d58713574a3079fe72ae63b06127961658293a8f05579d434e731bf24a3292e0 |
Hashes for docling_parse-2.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c07fe20d961f2af9a52a3982bf5443d2a214a09d562b8ae4de4c9034b9534579 |
|
MD5 | 389289195ac29edf9d586e43ee6e4ea7 |
|
BLAKE2b-256 | 51b223f5b1259d36a3a8270c44603afc8347ae6cc00d09df8292975237e43a46 |
Hashes for docling_parse-2.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 615e33874639d8c394eddf7ad6eb5a0b361b43fea91b997e9dfb580806b20feb |
|
MD5 | d9466435286ff6a5eb8184e71dfd7c12 |
|
BLAKE2b-256 | baed5602bdc72052c74961741e652374f727b582620500c8f4679ad696838cdb |
Hashes for docling_parse-2.0.3-cp310-cp310-macosx_14_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b0911580298174361acb484e4d08c6742e90c908050ac6c0b7d028c9b94990a |
|
MD5 | 3ede5d078168f66d84593d034c8dffb7 |
|
BLAKE2b-256 | 09bb62dc69b16b65567272047ae43fa869561d66495125233e2c7b6073753625 |
Hashes for docling_parse-2.0.3-cp310-cp310-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f1f40d4c0e2815d84128d2c8e444577a79d68c7cbc78451ab58702e3a46db2b |
|
MD5 | 21d15ad49d19036d9a2abcd777c303d6 |
|
BLAKE2b-256 | 8fb8c37c45b7f03fbdc26ddf2195a503f462a8069870de20e94520e662969f24 |
Hashes for docling_parse-2.0.3-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4da35cb9d4c25fd273571bd7bcbb1c6e4c80687dba2fc688b281b292fd72536a |
|
MD5 | ed4fe07a4beafb02e5d2711f66c777a7 |
|
BLAKE2b-256 | 27fb42c5362232589c79da6e18cf367722be1e4240470d2089748458e9602977 |
Hashes for docling_parse-2.0.3-cp310-cp310-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6747bbede758cef6c5c0e4bf9d8ccf348f86cb23e091a75605bbe47693045049 |
|
MD5 | 35f6bdbd71e2fcca9f017948021cda6c |
|
BLAKE2b-256 | db398c0d7fcfd863dc389b7c2096f2a6cc1a00d49e397d642ce2a38d4b080699 |