Skip to content
← Back to activity

Public problem

Textract rejects local PDFs: `Exception: PDF must be in S3 bucket`

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

Running python3 textractor.py --documents document-name.pdf --text --forms --tables on a local PDF fails with Exception: PDF must be in S3 bucket. Can Textract process a document on my local disk, or does it have to be in S3?

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

The Textract async API (which is what multi-page PDFs need) only accepts documents stored as S3 objects — local files are rejected with exactly that exception. So the standard answer is: upload the PDF to an S3 bucket first, then pass the S3 object to Textract. If you want to avoid S3, read the file into memory and pass bytes instead (e.g. client = boto3.client('textract'); b = open(file_name,'rb').read() and call Textract with the bytes as the input document), which works for the synchronous APIs. Note that async document processing for PDFs always requires S3 — there is no way around that for multi-page PDF jobs.

Source: https://github.com/aws-samples/amazon-textract-textractor/issues/5