Skip to main content

No project description provided

Project description

PDF GENIUS

PDF GENUIS is a powerful Python package that converts PDF documents into text using AI-powered optical character recognition (OCR). It currently supports both Google's Gemini and OpenAI's GPT-4 Vision models for text extraction, with an extensible architecture that makes it easy to add support for additional AI models.

Features

  • Extract text from PDF documents using state-of-the-art AI models
  • Support for multiple AI providers (Gemini and OpenAI)
  • Secure local storage of API keys
  • Command-line interface (CLI) for easy use
  • Extensible architecture for adding new AI models
  • Automatic handling of multi-page PDFs
  • Clean temporary file management

Installation

You can install the package using pip:

pip install pdfgenius

The package requires Python 3.7 or later.

System Dependencies

This package requires Poppler for PDF processing. Install it based on your operating system:

  • Linux (Ubuntu/Debian):

    sudo apt-get install poppler-utils
    
  • macOS:

    brew install poppler
    
  • Windows: Download and install poppler from poppler releases, then add the bin directory to your system PATH.

Quick Start

Extract text from a PDF using the default Gemini model:

# Store your API key (one-time setup)
pdfgenius keys add gemini "your-gemini-api-key"

# Extract text from PDF
pdfgenius extract document.pdf

API Key Management

The package provides secure local storage for your API keys. You can manage them using these commands:

# Add an API key
pdfgenius keys add gemini "your-gemini-api-key"
pdfgenius keys add openai "your-openai-api-key"

# List stored keys (shows partial keys for security)
pdfgenius keys list

# Delete a stored key
pdfgenius keys delete gemini

Command Line Usage

Basic Usage

# Extract using default settings (Gemini model)
pdfgenius extract document.pdf

# Specify output file
pdfgenius extract document.pdf -o output.txt

# Use OpenAI model
pdfgenius extract document.pdf -m openai

# Provide API key directly (without storing)
pdfgenius extract document.pdf -m openai --api-key "your-api-key"

Full Command Reference

# Show help
pdfgenius --help

# Show help for extract command
pdfgenius extract --help

# Show help for key management
pdfgenius keys --help

Python API

You can also use the package programmatically in your Python code:

from pdf_extractor import GeminiExtractor, OpenAIExtractor
from pdf_extractor.utils import process_pdf

# Using Gemini
extractor = GeminiExtractor(api_key="your-api-key")
extractor.initialize_client()
text = process_pdf("document.pdf", extractor)

# Using OpenAI
extractor = OpenAIExtractor(api_key="your-api-key")
extractor.initialize_client()
text = process_pdf("document.pdf", extractor)

Adding Support for New AI Models

The package is designed to be easily extensible. To add support for a new AI model:

  1. Create a new extractor class that inherits from BaseExtractor
  2. Implement the required methods
  3. Register the new extractor in the CLI

Example:

from pdf_extractor.extractors.base import BaseExtractor

class NewModelExtractor(BaseExtractor):
    def initialize_client(self):
        # Initialize your AI client
        pass

    def extract_text_from_image(self, image_path: Path) -> str:
        # Implement text extraction logic
        pass

Security

  • API keys are stored encrypted in the user's home directory
  • The encryption key is stored separately
  • Only partial keys are displayed when listing stored keys
  • Keys can be easily deleted when no longer needed

Environment Variables

The package also supports providing API keys through environment variables:

export GEMINI_API_KEY="your-gemini-api-key"
export OPENAI_API_KEY="your-openai-api-key"

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Acknowledgments

This package uses several open-source libraries:

  • pdf2image for PDF processing
  • google-generativeai for Gemini API
  • openai for OpenAI API
  • click for CLI interface
  • cryptography for secure key storage

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

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

pdfgenius-0.1.3.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

pdfgenius-0.1.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file pdfgenius-0.1.3.tar.gz.

File metadata

  • Download URL: pdfgenius-0.1.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pdfgenius-0.1.3.tar.gz
Algorithm Hash digest
SHA256 463e11e80304751b60847fa47b439137fae5129fd9c30bfcb911ea0a1e7b3a6a
MD5 3522103ffc1285c7edc7bbc6727cde4e
BLAKE2b-256 110db1753b32c7c46e5fb2e26e6a08de3ec9a9410477a72d01c6ce27f48e899c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdfgenius-0.1.3.tar.gz:

Publisher: python-publish.yml on TooSalty0000/pdfgenius

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

File details

Details for the file pdfgenius-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pdfgenius-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pdfgenius-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3bc2a905f150d7bb0e2e99b55a32dd89c5ed3f4a4690797bd960ae02d7824be3
MD5 fabb321e5c7cfe031fd96e052845f20b
BLAKE2b-256 282de85bf59d5311915f3e61cfc26466133ee78e8ba60ffcdb79f21a7e6c39f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdfgenius-0.1.3-py3-none-any.whl:

Publisher: python-publish.yml on TooSalty0000/pdfgenius

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