必須フィールド名を取得

Contents
[ ]

PDF フォームには、送信前にユーザーが入力する必要がある必須フィールドが含まれている場合があります。これらのフィールドは通常、フォームのプロパティで必須とマークされています。

  1. フォームオブジェクトを作成します。
  2. PDF ドキュメントをバインドします。
  3. 「pdf_form.field_names」を使用してすべてのフィールド名にアクセスします。
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 required field names
def get_required_field_names(infile):
    """Get required field names from a PDF document."""
    # Create Form object
    pdf_form = pdf_facades.Form()

    # Bind PDF document
    pdf_form.bind_pdf(infile)

    # Get required field names
    for field in pdf_form.field_names:
        if pdf_form.is_required_field(field):
            print(f"Required field: {field}")