New Tool Radar

AI PDF

How to Extract Tables and Form Data from a Scanned PDF with Amazon Textract

Extract tables, key-value form data and signatures from a scanned PDF with Amazon Textract AnalyzeDocument.

Schematic illustration of Textract extraction: send the PDF to AnalyzeDocument, read the key-value pairs, and rebuild the table from the cells.

Amazon Textract AnalyzeDocument returns five kinds of extraction: text, forms as key-value pairs, tables, signatures and query answers. You pick the kinds with FeatureTypes, for example TABLES and FORMS together. This guide runs it on one scanned form with a table and checks the result.

Prerequisites

An AWS account with Textract access and credentials, and a scanned PDF. Keep credentials out of shared files and delete uploads you no longer need.

Steps

1. Send the PDF to AnalyzeDocument

Call AnalyzeDocument with FeatureTypes TABLES, FORMS and SIGNATURES. Expected result: a response with a list of Block objects is returned.

2. Read the key-value pairs

Find the KEY_VALUE_SET blocks and read the pairs. Expected result: the form fields Name and Date appear as key-value pairs.

3. Read the table cells

Find the TABLE and CELL blocks and rebuild the table. Expected result: a four-row table with the same figures as the printed form.

4. Check the signature block

Find the SIGNATURE block in the response. Expected result: one signature block is present, with its location on the page.

Practice check: fictional scanned application form with a four-row table

The table below is fictional practice material. It lists the four checks for the Textract response.

Check Expected result
Blocks returned Block list present
Key-value pairs Name and Date present
Table rebuilt Four rows match the form
Signature block One signature present

Expected result. the response returns blocks, the Name and Date pairs are present, the four-row table matches the printed form, and one signature block is present.

Limits

  • Textract returns where it thinks things are; a cell it merges with its neighbour changes the table, so compare the rebuilt table with the scan.
  • UNTESTED – no OCR tool or AI tool was run; all results above are expected results. The practice file is fictional.

Sources

See all