ラジオボタンオプションを取得

Contents
[ ]

PDF フォームのラジオボタンフィールドはグループ化されたコントロールで、一度に 1 つのオプションしか選択できません。各グループにはフィールド名があり、各オプションには対応する値があります。

  1. フォームオブジェクトを作成します。
  2. PDF ドキュメントをバインドします。
  3. 選択したラジオボタンオプションを取得します。
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 radio button options
def get_radio_button_options(infile):
    """Get radio button options from a PDF document."""
    # Create Form object
    pdf_form = pdf_facades.Form()

    # Bind PDF document
    pdf_form.bind_pdf(infile)

    # Get radio button options by their names
    field_names = ["WorkType"]
    for field_name in field_names:
        options = pdf_form.get_button_option_current_value(field_name)
        print(f"Options for '{field_name}': {options}")