RenameAllFields($doc, "employee.name.check1");
RenameAllFields($doc, "submit");
$doc->Save($output_path . "forms_test1_cloned.pdf", 0);
echo nl2br("Done.\n");
//----------------------------------------------------------------------------------
// Sample:
// Flatten all form fields in a document.
// Note that this sample is intended to show that it is possible to flatten
// individual fields. PDFNet provides a utility function PDFDoc.FlattenAnnotations()
// that will automatically flatten all fields.
//----------------------------------------------------------------------------------
$doc = new PDFDoc($output_path . "forms_test1.pdf");
$doc->InitSecurityHandler();
// Traverse all pages
if (true) {
    $doc->FlattenAnnotations();
} else {
    for ($pitr = $doc->GetPageIterator(); $pitr->HasNext(); $pitr->Next()) {
        $page = $pitr->Current();
        $annots = $page->GetAnnots();
        if ($annots) {
            // Look for all widget annotations (in reverse order)
            for ($i = $annots->Size() - 1; $i >= 0; --$i) {
                if (!strcmp(annots . GetAt(i) . Get("Subtype") . Value() . GetName(), "Widget")) {
                    $field($annots->GetAt(i));
                    $field->Flatten($page);
                    // Another way of making a read only field is by modifying
                    // field's e_read_only flag:
                    //    field.SetFlag(Field::e_read_only, true);
                }
            }