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

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

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

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.2.tar.gz (12.2 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.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pdfplucker-0.2.2.tar.gz
  • Upload date:
  • Size: 12.2 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.2.tar.gz
Algorithm Hash digest
SHA256 9fd0c5697e9b7e046f3e591ee28bb2c60a2e5faf62b0a6c1f32e9416c7059720
MD5 2fa8dcafa6c61dfbe3a105a2d7dfb560
BLAKE2b-256 d048a9897752e5485560c9db02eff7ac6305ffc8d3d941b5d2cdf99e4af4689d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdfplucker-0.2.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: pdfplucker-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 12.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c6cc3a2f3fd3e47fece9744675d032b0f80916c61f2069ae05b0c72a8d0c2cbf
MD5 57bc8c3b27644435f8d3d0f00467a4e2
BLAKE2b-256 260a1f8e1ffd847caaca884465b64103caf6433afdea23fc07fd253342f34b35

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdfplucker-0.2.2-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