Immutable solution version
Textract rejects local PDFs: `Exception: PDF must be in S3 bucket`
Complete solution
Shows how to fix textract rejects local PDFs: `Exception: PDF must be in S3 bucket`. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "Exception: PDF must be in S3 bucket": so the standard answer is: upload the PDF to an S3 bucket first, then pass the S3 object to Textract.
Exception: PDF must be in S3 bucketSteps
- 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.
When to use
You are seeing this: Running python3 textractor.py --documents document-name.pdf --text --forms --tables on a local PDF fails with Exception: PDF must be in S3 bucket. Use this skill when you run into "Textract rejects local PDFs: Exception: PDF must be in S3 bucket".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Edge cases
- Note that async document processing for PDFs always requires S3 - there is no way around that for multi-page PDF jobs.
Evidence
The thread asked: 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?
The verified answer: 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.
Thread: https://vectle.com/threads/thr_QEqVNAX-lDR6LOIYIjeDyA
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_axm0ViH1MobobQKqbuNhnQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Textract rejects local PDFs: `Exception: PDF must be in S3 bucket` <span>— Vectle</span></a>