Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 262
Expand file tree
/
Copy path08-forms.py
More file actions
Latest commit
40 lines (32 loc) · 988 Bytes
/
Copy path08-forms.py
File metadata and controls
40 lines (32 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
importboto3
fromtrpimportDocument
# Document
documentName="employmentapp.png"
# Amazon Textract client
textract=boto3.client('textract')
# Call Amazon Textract
withopen(documentName, "rb") asdocument:
response=textract.analyze_document(
Document={
'Bytes': document.read(),
},
FeatureTypes=["FORMS"])
#print(response)
doc=Document(response)
forpageindoc.pages:
# Print fields
print("Fields:")
forfieldinpage.form.fields:
print("Key: {}, Value: {}".format(field.key, field.value))
# Get field by key
print("\nGet Field by Key:")
key="Phone Number:"
field=page.form.getFieldByKey(key)
if(field):
print("Key: {}, Value: {}".format(field.key, field.value))
# Search fields by key
print("\nSearch Fields:")
key="address"
fields=page.form.searchFieldsByKey(key)
forfieldinfields:
print("Key: {}, Value: {}".format(field.key, field.value))