【问题标题】:Unsupported Document format while using Amazon Textract,使用 Amazon Textract 时不受支持的文档格式,
【发布时间】:2020-10-30 02:36:35
【问题描述】:

当我尝试解析通过 amazon s3 访问的 pdf 文件时,它给了我一个错误,请求的文档格式不受支持。

我正在使用带有 boto3 的 Amazon textract。当我尝试解析通过 amazon s3 访问的 pdf 文件时,它给了我一个错误,Request has unsupported do 格式。我对此很陌生,在 textract 的文档中提到确实支持 pdf 文件。

这是我正在使用的代码。

import boto3
textractClient = boto3.client('textract',region_name='us-east-1')
response = textractClient.detect_document_text(
        Document={'S3Object': {'Bucket': 'bucketName', 'Name': 'filename.pdf'}})
blocks = response['Blocks']

这给了我错误,请求的文档格式不受支持。

【问题讨论】:

    标签: python python-3.x amazon-textract


    【解决方案1】:

    detect_document_text() 是一个同步 API,只支持 PNG 或 JPG 图片。

    如果您想处理 PDF 文件,您应该使用名为 start_document_text_detection() 的异步 API。

    https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/textract.html#Textract.Client.start_document_text_detection

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 2022-12-09
      • 2016-05-30
      • 2013-09-28
      • 2021-10-17
      • 2012-03-26
      • 1970-01-01
      相关资源
      最近更新 更多