//
// Yet another option is to pre-populate field entries with dummy text. When
// you edit the field values using PDFNet the new field appearances will match
// the old ones.
$doc->RefreshFieldAppearances();
$doc->Save($output_path . "forms_test1.pdf", 0);
echo "Done.\n";
//----------------------------------------------------------------------------------
// Example 2:
// Fill-in forms / Modify values of existing fields.
// Traverse all form fields in the document (and print out their names).
// Search for specific fields in the document.
//----------------------------------------------------------------------------------
$doc = new PDFDoc($output_path . "forms_test1.pdf");
$doc->InitSecurityHandler();
$itr = $doc->GetFieldIterator();
for (; $itr->HasNext(); $itr->Next()) {
    echo nl2br("Field name: " . $itr->Current()->GetName() . "\n");
    echo nl2br("Field partial name: " . $itr->Current()->GetPartialName() . "\n");
    echo "Field type: ";
    $type = $itr->Current()->GetType();
    $str_val = $itr->Current()->GetValueAsString();
    switch ($type) {
        case Field::e_button:
            echo nl2br("Button\n");
            break;
        case Field::e_radio:
            echo nl2br("Radio button: Value = " . $str_val . "\n");
            break;
        case Field::e_check:
            $itr->Current()->SetValue(true);