Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

AmazonTextractConverter

Convert images and single-page PDFs to Haystack Documents using AWS Textract for OCR and structured data extraction.

Key Features

  • Extracts text from images (JPEG, PNG, TIFF, BMP) and single-page PDFs using AWS Textract.
  • Supports plain text OCR as well as structured data extraction (tables, forms, layouts).
  • Supports natural language queries to extract specific information from documents.
  • Automatically adds QUERIES feature type when queries are provided at runtime.
  • Returns both Haystack Documents and raw Textract API responses.
  • AWS credentials are resolved through AWS Secret parameters or the standard boto3 credential chain.

Configuration

  1. Drag the AmazonTextractConverter component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Create secrets for your AWS credentials. Use AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_DEFAULT_REGION as the environment variable names. For instructions, see Create Secrets.
    2. Optionally set feature_types to enable table extraction (TABLES), form extraction (FORMS), layout analysis (LAYOUT), or signature detection (SIGNATURES).
  4. Go to the Advanced tab to configure store_full_path and boto3_config.

Connections

AmazonTextractConverter receives a list of file sources (paths or ByteStream objects). It outputs a list of Document objects containing the extracted text and a list of raw Textract API responses.

Source Code

To check this component's source code, open converter.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  AmazonTextractConverter:
type: haystack_integrations.components.converters.amazon_textract.AmazonTextractConverter
init_parameters:
aws_access_key_id:
type: env_var
env_vars:
- AWS_ACCESS_KEY_ID
strict: false
aws_secret_access_key:
type: env_var
env_vars:
- AWS_SECRET_ACCESS_KEY
strict: false
aws_region_name:
type: env_var
env_vars:
- AWS_DEFAULT_REGION
strict: false
feature_types:

Using the Component in a Pipeline

# haystack-pipeline
components:
AmazonTextractConverter:
type: haystack_integrations.components.converters.amazon_textract.AmazonTextractConverter
init_parameters:
aws_access_key_id:
type: env_var
env_vars:
- AWS_ACCESS_KEY_ID
strict: false
aws_secret_access_key:
type: env_var
env_vars:
- AWS_SECRET_ACCESS_KEY
strict: false
aws_region_name:
type: env_var
env_vars:
- AWS_DEFAULT_REGION
strict: false
feature_types:
- TABLES
- FORMS

document_splitter:
type: haystack.components.preprocessors.document_splitter.DocumentSplitter
init_parameters:
split_by: word
split_length: 250
split_overlap: 30

connections:
- sender: AmazonTextractConverter.documents
receiver: document_splitter.documents

max_runs_per_component: 100

metadata: {}

Parameters

Inputs

ParameterTypeDescription
sourcesList[Union[str, Path, ByteStream]]A list of file paths, Path objects, or ByteStream objects to convert. Supported formats are JPEG, PNG, TIFF, BMP, and single-page PDF files (up to 10 MB).
metaOptional[Union[Dict[str, Any], List[Dict[str, Any]]]]Metadata to add to all documents, or a list of metadata dicts (one per source).
queriesOptional[List[str]]A list of natural language queries to extract specific information from documents. Automatically enables the QUERIES Textract feature.

Outputs

ParameterTypeDescription
documentsList[Document]The extracted text as Haystack Documents.
raw_textract_responseList[Dict]The raw API responses from AWS Textract for each input file.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
aws_access_key_idOptional[Secret]Secret.from_env_var("AWS_ACCESS_KEY_ID", strict=False)The AWS access key ID.
aws_secret_access_keyOptional[Secret]Secret.from_env_var("AWS_SECRET_ACCESS_KEY", strict=False)The AWS secret access key.
aws_session_tokenOptional[Secret]Secret.from_env_var("AWS_SESSION_TOKEN", strict=False)The AWS session token for temporary credentials.
aws_region_nameOptional[Secret]Secret.from_env_var("AWS_DEFAULT_REGION", strict=False)The AWS region to use (for example, us-east-1).
aws_profile_nameOptional[Secret]Secret.from_env_var("AWS_PROFILE", strict=False)The AWS named profile to use.
feature_typesOptional[List[str]]NoneTextract feature types to enable. Options are TABLES, FORMS, SIGNATURES, and LAYOUT. When not set, uses basic text detection only. The QUERIES type is added automatically when queries are provided at runtime.
store_full_pathboolFalseWhether to store the full file path in document metadata, or just the filename.
boto3_configOptional[Dict[str, Any]]NoneA dictionary of additional configuration options for the boto3 Textract client.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
sourcesList[Union[str, Path, ByteStream]]A list of file paths or streams to convert.
metaOptional[Union[Dict, List[Dict]]]NoneMetadata to add to the resulting documents.
queriesOptional[List[str]]NoneNatural language queries to extract specific information.