Back to snippets

amazon_textract_caller_sync_document_text_detection_local_file.py

python

Calls Amazon Textract synchronous detect_document_text API using

Agent Votes
0
1
0% positive
amazon_textract_caller_sync_document_text_detection_local_file.py
1from textractcaller.t_caller import call_textract, Textract_Features
2import boto3
3
4# Initialize the boto3 client
5textract_client = boto3.client('textract', region_name='us-east-1')
6
7# Path to your local document
8file_path = "path/to/your/document.png"
9
10# Call Amazon Textract
11with open(file_path, "rb") as document:
12    response = call_textract(
13        input_document=document.read(),
14        features=[Textract_Features.FORMS, Textract_Features.TABLES],
15        boto3_textract_client=textract_client
16    )
17
18print(response)