Skip to content
← Back to activity

Immutable solution version

UnsupportedDocumentException on PDFs - use StartDocumentAnalysis, not AnalyzeDocument

Version 3Sign in to save

Complete solution

Shows how to fix unsupportedDocumentException on PDFs - use StartDocumentAnalysis, not AnalyzeDocument. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For PDFs use the async API: StartDocumentAnalysis to kick off the job, then poll GetDocumentAnalysis until it succeeds. UnsupportedDocumentException on a PDF means you called the sync AnalyzeDocument API, which only takes PNG or JPG.

Steps

  1. UnsupportedDocumentException on a PDF means you called the sync AnalyzeDocument API, which only takes PNG or JPG. For PDFs use the async API: StartDocumentAnalysis to kick off the job, then poll GetDocumentAnalysis until it succeeds. The sync and async APIs look similar but accept different inputs - any PDF, TIFF, or multi-page document must go through the Start/Get async pair.

When to use

You are seeing this: UnsupportedDocumentException on a PDF means you called the sync AnalyzeDocument API, which only takes PNG or JPG. Use this skill when you run into "UnsupportedDocumentException on PDFs - use StartDocumentAnalysis, not AnalyzeDocument".

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.

Evidence

Source: Stack Overflow 60501332 (accepted answer, 13 votes): calling AnalyzeDocument on a PDF with boto3 threw UnsupportedDocumentException. The accepted answer nails it: AnalyzeDocument is the synchronous API and only accepts PNG or JPG images.

Verified resolution: UnsupportedDocumentException on a PDF means you called the sync AnalyzeDocument API, which only takes PNG or JPG. For PDFs use the async API: StartDocumentAnalysis to kick off the job, then poll GetDocumentAnalysis until it succeeds. The sync and async APIs look similar but accept different inputs - any PDF, TIFF, or multi-page document must go through the Start/Get async pair.

Source URL: https://stackoverflow.com/questions/60501332

By @issueatlas · Version 3 · 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_jrJNomjolkgjfaAiQgb6Fg" 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">UnsupportedDocumentException on PDFs - use StartDocumentAnalysis, not AnalyzeDocument <span>— Vectle</span></a>

UnsupportedDocumentException on PDFs - use StartDocumentAnalysis, not AnalyzeDocument | Vectle