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
QUERIESfeature 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
- Drag the
AmazonTextractConvertercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Create secrets for your AWS credentials. Use
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, andAWS_DEFAULT_REGIONas the environment variable names. For instructions, see Create Secrets. - Optionally set
feature_typesto enable table extraction (TABLES), form extraction (FORMS), layout analysis (LAYOUT), or signature detection (SIGNATURES).
- Create secrets for your AWS credentials. Use
- Go to the Advanced tab to configure
store_full_pathandboto3_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
| Parameter | Type | Description |
|---|---|---|
sources | List[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). |
meta | Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] | Metadata to add to all documents, or a list of metadata dicts (one per source). |
queries | Optional[List[str]] | A list of natural language queries to extract specific information from documents. Automatically enables the QUERIES Textract feature. |
Outputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | The extracted text as Haystack Documents. |
raw_textract_response | List[Dict] | The raw API responses from AWS Textract for each input file. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
aws_access_key_id | Optional[Secret] | Secret.from_env_var("AWS_ACCESS_KEY_ID", strict=False) | The AWS access key ID. |
aws_secret_access_key | Optional[Secret] | Secret.from_env_var("AWS_SECRET_ACCESS_KEY", strict=False) | The AWS secret access key. |
aws_session_token | Optional[Secret] | Secret.from_env_var("AWS_SESSION_TOKEN", strict=False) | The AWS session token for temporary credentials. |
aws_region_name | Optional[Secret] | Secret.from_env_var("AWS_DEFAULT_REGION", strict=False) | The AWS region to use (for example, us-east-1). |
aws_profile_name | Optional[Secret] | Secret.from_env_var("AWS_PROFILE", strict=False) | The AWS named profile to use. |
feature_types | Optional[List[str]] | None | Textract 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_path | bool | False | Whether to store the full file path in document metadata, or just the filename. |
boto3_config | Optional[Dict[str, Any]] | None | A 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
sources | List[Union[str, Path, ByteStream]] | A list of file paths or streams to convert. | |
meta | Optional[Union[Dict, List[Dict]]] | None | Metadata to add to the resulting documents. |
queries | Optional[List[str]] | None | Natural language queries to extract specific information. |
Related Information
Was this page helpful?