Skip to main content

A small Python toolkit to create, view, and OCR PDF files.

Project description

RabbitPDF

RabbitPDF is a small Python library for PDF workflows:

  • create PDFs from text, lines, or images;
  • open PDFs in the local browser/default viewer;
  • run OCR on PDF pages and return plain text.

Version 0.1.0 is intentionally compact and friendly for scripts, CLIs, and small apps.

Install

pip install RabbitPDF

For OCR support:

pip install "RabbitPDF[ocr]"

OCR also needs the Tesseract binary installed on the machine.

Quick Start

from rabbitpdf import PDFCreator, PDFViewer, ocr_pdf

PDFCreator(title="Invoice").create_from_text(
    "Hello from RabbitPDF!",
    "hello.pdf",
)

PDFViewer("hello.pdf").open()

text = ocr_pdf("scanned.pdf", lang="por+eng")
print(text)

CLI

Create a PDF:

rabbitpdf create hello.pdf --text "Hello from RabbitPDF"

If the console script is not on your PATH, use:

python -m rabbitpdf create hello.pdf --text "Hello from RabbitPDF"

Create a PDF from a text file:

rabbitpdf create output.pdf --text-file input.txt --title "My Document"

Create a PDF from images:

rabbitpdf create album.pdf --images page-1.png page-2.jpg --page-size A4

Open a PDF:

rabbitpdf view output.pdf

Run OCR:

rabbitpdf ocr scanned.pdf --lang por+eng --output scanned.txt

Build for PyPI

python -m pip install -e ".[dev]"
python -m pytest
python -m build
twine check dist/*
twine upload dist/*

Notes

  • PDFCreator uses ReportLab.
  • PDFViewer delegates rendering to the local browser/default PDF viewer.
  • ocr_pdf() uses PyMuPDF to render pages and pytesseract to read text.
  • Tesseract language packs must be installed separately, for example Portuguese (por) and English (eng).

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

rabbitpdf-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

rabbitpdf-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file rabbitpdf-0.1.0.tar.gz.

File metadata

  • Download URL: rabbitpdf-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rabbitpdf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f59443e14e2597fcf7174aae0e6080953ca745df0b5ff10c7d06fdd448a3e51
MD5 1e781fcc3a2cde3177ebb21611dc2e2f
BLAKE2b-256 5e4aea037b2fab53b3fe532afe346f777695fadc3a4dbfdc963f63f7ed00d999

See more details on using hashes here.

Provenance

The following attestation bundles were made for rabbitpdf-0.1.0.tar.gz:

Publisher: publish.yml on juca-soft/RabbitPDF

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

File details

Details for the file rabbitpdf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rabbitpdf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rabbitpdf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00f4ea963bbe266028a68e1953d41f5c25b63e05631f7784921942f819093e4b
MD5 908e470641170f3c2adb746e5ca2d928
BLAKE2b-256 f89b61aef5a19f52d8c062405e4ea85c78747d0c006d258a5bca0147b35ae6e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for rabbitpdf-0.1.0-py3-none-any.whl:

Publisher: publish.yml on juca-soft/RabbitPDF

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