フィールドファサードを取得
Contents
[
Hide
]
PDF フォームには、テキストボックス、チェックボックス、ラジオボタンなど、ユーザーがデータを入力できるフィールドが含まれています。これらのフォームをプログラム的に処理するには、多くの場合、これらのフィールドの現在の値を取得する必要があります。
- Form オブジェクトを作成します。
- PDF ドキュメントをフォームオブジェクトにバインドします。
- フィールド値を取得します。
from io import FileIO
import sys
from os import path
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades
sys.path.append(path.join(path.dirname(__file__), ".."))
from config import set_license, initialize_data_dir
# Get field values
def get_field_values(infile):
"""Get field values from a PDF document."""
# Create Form object
pdf_form = pdf_facades.Form()
# Bind PDF document
pdf_form.bind_pdf(infile)
# Get field values by their names
field_names = ["First Name", "Last Name"]
for field_name in field_names:
value = pdf_form.get_field(field_name)
print(f"Value of '{field_name}': {value}")