-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform-data.py
More file actions
40 lines (24 loc) · 946 Bytes
/
Copy pathform-data.py
File metadata and controls
40 lines (24 loc) · 946 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
import pymupdf
filename = input("Filename: ")
doc = pymupdf.open(filename)
# Iterate through each page
for page_num in range(len(doc)):
page = doc[page_num]
print(f"Page {page_num + 1}:")
# Get all widgets (form fields) on the page
widgets = page.widgets()
if not widgets:
print(" No form fields found on this page.")
continue
# Iterate through each widget and extract data
for widget in widgets:
field_name = widget.field_name # Name of the form field
field_value = widget.field_value # Value entered in the field
field_type = widget.field_type_string # Type of the field (e.g., Text, CheckBox)
print(f" Field Name: {field_name}")
print(f" Field Value: {field_value}")
print(f" Field Type: {field_type}")
print()
if(field_type == "ListBox"):
print(widget.choice_values)
doc.close()