データを抽出する AcroForms

PDF ドキュメントの個別のフィールドから値を取得する

フォームフィールドのgetValue() メソッドは、特定のフィールドの値を取得することを可能にします。

値を取得するには、DocumentオブジェクトのFormコレクションからフォームフィールドを取得します。

この例では、textBoxFieldを選択し、getValue() メソッドを使用してその値を取得します。


    // ドキュメントを開く
    $document = new Document($inputFile);

    // フィールドを取得
    $textBoxField = $document->getForm()->get("textbox1");

    // フィールド名を取得
    $responseData = "PartialName: " . $textBoxField->getPartialName();

    // フィールド値を取得
    $responseData = $responseData . " Value: " . $textBoxField->getValue();
    $document->close();