Skip to main content

WizardExtract Banner


Wizard Extract

PyPI - Version PyPI - Downloads/month License

WizardExtract is a Python library for reliable text extraction from PDFs, Office documents, and images. It supports local OCR with Tesseract and cloud OCR with Azure Document Intelligence. It provides page and sheet selection, hybrid PDF handling that combines native text with OCR, and deterministic I/O. With Azure prebuilt-layout it can also return tables and key-value pairs.


Contents


Installation

Requires Python 3.9+.

pip install wizardextract

Optional extras:

  • Azure OCR: pip install "wizardextract[azure]"

For OCR capabilities, ensure you have Tesseract installed on your system.


Quick start

import wizardextract as we

text = we.extract_text("example.pdf")
print(text)

API overview

Method Purpose
extract_text Local text extraction with optional Tesseract OCR
extract_text_azure Cloud extraction via Azure (text, tables, key-value)

Text extraction

Parameters

  • input_data: [str, bytes, Path]
  • extension: The file extension, required only if input_data is bytes.
  • pages: Page/sheet selection.
    • Paged (PDF, DOCX, TIFF): 1, "1-3", [1, 3, "5-8"]
    • Excel (XLSX/XLS): sheet index (int), name (str), or mixed list
  • ocr: Enables OCR using Tesseract. Applies to PDF/DOCX and image-based files.
  • language_ocr: Language code for OCR. Defaults to 'eng'.

Examples

Basic:

import wizardextract as we

txt = we.extract_text("docs/report.pdf")

From bytes:

from pathlib import Path
import wizardextract as we

raw = Path("img.png").read_bytes()
txt_img = we.extract_text(raw, extension="png")

Paged selection and OCR:

import wizardextract as we

sel = we.extract_text("docs/big.pdf", pages=[1, 3, "5-7"])
ocr_txt = we.extract_text("scan.tiff", ocr=True, language_ocr="ita")

Supported Formats

Format OCR Option
PDF Optional
DOC No
DOCX Optional
XLSX No
XLS No
TXT No
CSV No
JSON No
HTML No
HTM No
TIF Default
TIFF Default
JPG Default
JPEG Default
PNG Default
GIF Default

Azure OCR

Parameters

  • input_data: [str, bytes, Path]
  • extension: File extension when bytes are passed.
  • language_ocr: OCR language code (ISO-639).
  • pages: Page selection (int, "1,3,5-7", or list).
  • azure_endpoint: Azure Document Intelligence endpoint URL.
  • azure_key: Azure API key.
  • azure_model_id: "prebuilt-read" (text only) or "prebuilt-layout" (text + tables + key-value).
  • hybrid: If True, for PDFs: native text via PyMuPDF and images via OCR.

Example

import wizardextract as we

res = we.extract_text_azure(
    "invoice.pdf",
    language_ocr="ita",
    azure_endpoint="https://<resource>.cognitiveservices.azure.com/",
    azure_key="<KEY>",
    azure_model_id="prebuilt-layout",
    hybrid=True,
)

print(res.text)
print(res.pretty_tables[:1])
print(res.key_value)

License

AGPL-3.0-or-later.

RESOURCES


Contact & Author

Author: Mattia Rubino
Email: textwizard.dev@gmail.com

Metadata

Release files for wizardextract 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wizardextract 1.0.1
File Size Uploaded Provenance Actions
wizardextract-1.0.1.tar.gz 60.7 kB Without provenance Details for wizardextract-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wizardextract 1.0.1
File Interpreter ABI Platform Actions
wizardextract-1.0.1-py3-none-any.whl Python 3 none any Details for wizardextract-1.0.1-py3-none-any.whl

Total release size: 116.8 kB

Release files / wizardextract-1.0.1.tar.gz

Download URL wizardextract-1.0.1.tar.gz
Size 60.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4db5ce2e775c32de35420245c78ecfae6bcd02c821ba2f354dd3cf5955f8162a
BLAKE2b-256 checksum
How to use checksums
907d90cffdab94c94562445e3601c7b485062e20dad7eb4bb21289fdf540dda7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Release files / wizardextract-1.0.1-py3-none-any.whl

Download URL wizardextract-1.0.1-py3-none-any.whl
Size 56.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c3d72e043fc33cf4d9db2a570efe1cc96a40b51d16e658699e4ae6fc95fac24
BLAKE2b-256 checksum
How to use checksums
321f8c8a4b74b20b5474c2c7e3c0c3e36dfb335005e0111fc5f0035812d15194
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Security for wizardextract 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page