mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-09-01 14:53:07 +08:00
33f7e7da66
feat:support agent skills
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Analyze PDF form fields and output their structure.
|
|
Usage: python analyze_form.py <pdf_file>
|
|
"""
|
|
|
|
import sys
|
|
import json
|
|
|
|
def analyze_form(pdf_path):
|
|
"""Analyze form fields in a PDF file."""
|
|
# This is a mock implementation for testing
|
|
# In production, would use pypdf or pdfrw
|
|
|
|
print(f"Analyzing PDF: {pdf_path}")
|
|
print("=" * 50)
|
|
|
|
# Mock form fields for demonstration
|
|
fields = {
|
|
"name": {"type": "text", "required": True},
|
|
"email": {"type": "text", "required": True},
|
|
"date": {"type": "date", "required": False},
|
|
"agree_terms": {"type": "checkbox", "required": True},
|
|
"signature": {"type": "signature", "required": True}
|
|
}
|
|
|
|
print("\nDiscovered Form Fields:")
|
|
print("-" * 30)
|
|
for field_name, props in fields.items():
|
|
required_str = "[REQUIRED]" if props["required"] else "[optional]"
|
|
print(f" {field_name}: {props['type']} {required_str}")
|
|
|
|
print("\n" + "=" * 50)
|
|
print("Analysis complete.")
|
|
|
|
# Output JSON for programmatic use
|
|
return json.dumps(fields, indent=2)
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python analyze_form.py <pdf_file>")
|
|
sys.exit(1)
|
|
|
|
result = analyze_form(sys.argv[1])
|
|
print("\nJSON Output:")
|
|
print(result)
|