我正在使用 boto3(用于 python 的 aws sdk)来分析文档(pdf)以获取表单键:值对。
import boto3
def process_text_analysis(bucket, document):
# Get the document from S3
s3_connection = boto3.resource('s3')
s3_object = s3_connection.Object(bucket, document)
s3_response = s3_object.get()
# Analyze the document
client = boto3.client('textract')
response = client.analyze_document(Document={'S3Object': {'Bucket': bucket, 'Name': document}},
FeatureTypes=["FORMS"])
process_text_analysis('francismorgan-01', '709 Privado M SURESTE.pdf')
我已使用分析文档遵循 AWS 文档,但在运行函数时出现错误。
botocore.errorfactory.UnsupportedDocumentException: An error occurred (UnsupportedDocumentException) when calling the AnalyzeDocument operation: Request has unsupported document format
我错过了什么吗?
最佳答案
AnalyzeDocument是一个同步 API,只支持 PNG 或 JPG 图片。
由于您要处理 PDF 文件,因此您需要使用 Amazon Textract 异步 API 例如 StartDocumentAnalysis , StartDocumentTextDetection
关于python - AWS Textract - UnsupportedDocumentException - PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60501332/