Skip to main content

Docling wrapper for PDF parsing

Project description

PdfPlucker

PyPI version Python 3.9+ License: MIT

PdfPlucker is a powerful wrapper for the Docling library, specifically designed for batch processing PDF files. It provides users with fine-grained control over processing parameters and output configuration through a simple command-line interface.

Features

  • Comprehensive Extraction: Extract text, tables, and images from PDF files with high fidelity
  • Structured Outputs: Get results in well-organized JSON and Markdown formats
  • High Performance: Process multiple documents simultaneously with parallel processing
  • Hardware Acceleration: Support for both CPU and CUDA for faster processing
  • Simple Interface: Intuitive CLI commands for easy parameter control
  • Batch Processing: Handle directories of PDFs effortlessly

Installation

PdfPlucker requires Python 3.9 or higher. To install, simply run the following command:

pip install pdfplucker

Or install from source:

git clone https://github.com/rafaelghiorzi/pdfplucker.git
cd pdfplucker
pip install -r requirements.txt

Requirements

  • Python 3.9+
  • For CUDA support: NVIDIA GPU with CUDA drivers installed
  • Additional dependencies are automatically installed with the package

Basic Usage

PdfPlucker has a built-in CLI to run the processor. The basic command structure is:

pdfplucker --source /path/to/pdf

This will process the PDF file and save the results to ./results by default.

Command-line Options

Option Description
-s, --source Path to PDF files (directory or single file)
-o, --output Path to save processed information (default: ./results)
-f, --folder-separation Create separate folders for each PDF
-i, --images Path to save extracted images (ignored if --folder-separation is active)
-t, --timeout Time limit in seconds for processing each PDF (default: 600)
-w, --workers Number of parallel processes (default: 4)
-d, --device Processing device: CPU, CUDA, or AUTO (default: AUTO)
-m, --markdown Export the document in an additional markdown file
-ocr, --force-ocr Force text recognition using ocr even with digital documents

Examples

Process a single PDF file:

pdfplucker --source document.pdf

Process all PDFs in a directory:

pdfplucker --source ./documents/ --output ./extracted_data

Create separate folders for each PDF and include markdown output:

pdfplucker --source ./documents/ --folder-separation --markdown

Specify output location for extracted images:

pdfplucker --source document.pdf --images ./images

Use CUDA for processing with 8 workers:

pdfplucker --source ./documents/ --device CUDA --workers 8

Advanced Usage

For processing large batches of PDFs, you can use the folder separation option combined with multiple workers:

pdfplucker --source ./pdf_collection/ --folder-separation --workers 8 --timeout 300 --force-ocr

This will create a separate folder for each PDF, use 8 parallel processes, set a timeout of 5 minutes per PDF and force ocr usage for text recognition.

Output Structure

PdfPlucker generates structured outputs in the following formats:

JSON Output

The JSON output contains:

  • Document metadata (title, author, date, etc.)
  • Extracted text divided into sections (title, text)
  • Table data with structure preserved and subtitles, if they exist
  • References to extracted images, with subtitles, if they exist

Example structure:

{
    "metadata": {
        "format": "PDF 1.7",
        "title": "Microsoft Word - Sample Title",
        "..."
        "producer": "Microsoft: Print To PDF",
        "creationDate": "D:20250401144737-03'00'",
        "filename": "file.pdf"
    },
    "sections": [
        {
            "title": "Big Title!",
            "text": "Following text after title"
        },
    ],
    "images": [
      {
        "self_ref" : "#picture/1",
        "ref" : "path/to/image.png",
        "subtitle" : "possible subtitle"
      }
    ],
    "tables": [
      {
        "self_ref" : "#table/1",
        "subtitle" : "possible subtitle",
        "table" : {"table in dict format"}
      }
    ]
}

Markdown Output

When enabled with the --markdown flag, PdfPlucker will generate a readable Markdown file that includes:

  • Formatted document text
  • Tables rendered in Markdown syntax
  • Embedded images with base64 encoding

Troubleshooting

Common Issues

  • MemoryError: Try reducing the number of workers or processing larger PDFs individually
  • CUDA not detected: Ensure you have compatible NVIDIA drivers installed and visible to Python
  • Timeout errors: Increase the timeout value for complex or large documents
  • Missing images: Check file permissions in the output directory

Getting Help

If you encounter issues not covered here, please open an issue on GitHub with:

  • The command you ran
  • The error message
  • Your system specifications (OS, Python version, etc.)

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! If you have suggestions for improvements or new features, please:

  1. Check existing issues and pull requests
  2. Fork the repository
  3. Create a new branch for your feature
  4. Add your changes
  5. Submit a pull request

Acknowledgments

  • Docling for the core PDF processing capabilities
  • All contributors and users of PdfPlucker

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdfplucker-0.2.6.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdfplucker-0.2.6-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file pdfplucker-0.2.6.tar.gz.

File metadata

  • Download URL: pdfplucker-0.2.6.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pdfplucker-0.2.6.tar.gz
Algorithm Hash digest
SHA256 fcd460d21b0947bfac8f5d3406697be4d4ba04bc6978769ceda2028a57267774
MD5 3e67b0ff77a2869ff184d8ade0daaefa
BLAKE2b-256 137fe61a27a782961882972192fd3afec292dfd93947acb84773ee779d9053f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdfplucker-0.2.6.tar.gz:

Publisher: release.yaml on rafaelghiorzi/pdfplucker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pdfplucker-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: pdfplucker-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pdfplucker-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4b7f7860caad54594ade46474f7a81cee70cc3f0618c57987f20047a7c7b09e1
MD5 1aa5b510c90993e0eb4299bef4ef5c69
BLAKE2b-256 9770b5765dcaf7fe310d5a708f5a8069a5e3f994ac826bda29b288aa19d36565

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdfplucker-0.2.6-py3-none-any.whl:

Publisher: release.yaml on rafaelghiorzi/pdfplucker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page