0

We are trying integrate amazon Textract api in our node.js application. we are facing some issue, FeatureType parameter while processing image. we need to achieve the below option via api:

enter image description here

We are not finding the option in the AWS JavaScript SDK.

export type FeatureType = "TABLES"|"FORMS"|string;

I'm trying this code:

const params = {
            Document: {
                /* required */
                Bytes: Buffer.from(fileData)
            },
            FeatureTypes: [""] // here i'm facing issue, if i pass "TABLES"|"FORMS" it working
        };
        var textract = new AWS.Textract({
            region: awsConfig.awsRegion,
            accessKeyId: awsConfig.awsAccesskeyID,
            secretAccessKey: awsConfig.awsSecretAccessKey
        })
        textract.analyzeDocument(params, (err, data) => {
            console.log(err, data)
            if (err) {
                return resolve(err)
            } else {
                resolve(data)
            }
        })

Getting this error:

InvalidParameterType: Expected params.FeatureTypes[0] to be a string

If I pass "TABLES"|"FORMS" its working but I need Raw Text option.

Thanks in advance

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Robert
  • 3,373
  • 1
  • 18
  • 34

1 Answers1

1

You have been calling the analyzeDocument() function:

Analyzes an input document for relationships between detected items.

It returns various types of text:

'BlockType': 'KEY_VALUE_SET'|'PAGE'|'LINE'|'WORD'|'TABLE'|'CELL'|'SELECTION_ELEMENT',

The LINE and WORD blocks seem to match your requirements.

Alternatively, there is also a detectDocumentText() function:

Detects text in the input document. Amazon Textract can detect lines of text and the words that make up a line of text.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470