aws-samples/amazon-textract-textractor

Analyze documents with Amazon Textract and generate output in multiple formats.

What it solves

Working directly with Amazon Textract, a document intelligence service, requires handling raw API calls and parsing complex JSON responses. This package provides a high-level Python interface that simplifies the process, letting you focus on building applications rather than low-level plumbing. It turns Textract's output into convenient objects like lines, tables, and key-value pairs, and supports common document types such as PDFs, images, forms, IDs, and receipts.

How it works

You install it with pip install amazon-textract-textractor and create a Textractor instance with your AWS credentials (e.g., Textractor(profile_name="default")). Then you call methods like:

  • detect_document_text for plain text recognition.
  • analyze_document with features like TABLES or FORMS for structured extraction.
  • analyze_id for identity documents.
  • analyze_expense for receipts and expenses.

The returned document objects give you direct access to extracted data—for example, .lines for text lines, .tables for tables (which can be exported to Excel), or .get("email") for a form field with fuzzy matching. The package also handles synchronous and asynchronous calls, and includes a command-line interface for quick tasks like analyzing and overlaying results.

Who it's for

Developers building document processing workflows—from small one-off scripts to complex distributed pipelines—who want a simpler, more Pythonic way to use Amazon Textract. It's also useful for data scientists and analysts who need to extract structured information from documents without digging into AWS SDK details.

Highlights

  • Minimal setup: just two lines to start extracting.
  • Reusable Textractor instance for multiple requests.
  • Supports text, tables, forms, IDs, and expenses.
  • Tables can be exported to Excel, and with optional pandas extra to CSV/DataFrames.
  • Optional PDF rasterization via pdfium or pdf extras.
  • Optional torch extra for better word search and matching.
  • Includes a CLI for direct terminal use.
  • Apache 2.0 licensed and open-source.

Related

  • Project
  • Project
  • Project
  • Project
  • Project