Skip to content

DetectDocumentText

Source: src/AWS/Textract/DetectDocumentText.ts

Runtime binding for textract:DetectDocumentText — synchronous OCR that detects lines and words of text in a JPEG, PNG, PDF, or TIFF document.

Textract is a pure pay-per-call service with no resource to manage: the binding takes no arguments and grants the function textract:DetectDocumentText (the action has no resource-level IAM). Pass the document as raw bytes (Document.Bytes) or as an S3 object reference (Document.S3Object) — raw distilled types, no marshalling.

// init
const detectDocumentText = yield* AWS.Textract.DetectDocumentText();
// runtime
const result = yield* detectDocumentText({
Document: { Bytes: documentBytes },
});
const lines = (result.Blocks ?? [])
.filter((block) => block.BlockType === "LINE")
.map((block) => block.Text);