Here\'s the situation. I have a PDF with automatically generated pdf form field names. The problem is that these names are not very user friendly. They look something like :
The full name of an AcroForm field isn't explicitly stored within a field. It's actually derived from a hierarchy of fields, with a dot delimited list of ancestors appearing on the left.
Simply renaming a field from 'topmostSubform[0].Page1[0].Website_Address[0]' to 'WebsiteAddress' is therefore unlikely to produce a correct result.
You'll find section 8.6.2 'Field Dictionaries' of the PDF reference provides a good explanation of how field naming works ;-)
Basically, each field in an AcroForm is define by a dictionary, which may contain certain optional entries pertaining to a field's name.
Key '/T' specifies the partial name. In your question, 'topmostSubform[0]', 'Page1[0]', and Website_Address[0], all represent partial names.
Key '/TU' specifies an alternative 'user-friendly' name for fields, which can be used in place of the actual field name for identifying fields in a user interface.
Instead of renaming the field in question, think about adding a /TU entry!
The example below uses ABCpdf to iterate through all the fields in an AcroForm and insert an alternate name into a field based on its partial name.
VBScript:
Set theDoc = CreateObject("ABCpdf7.Doc")
theDoc.Read "myForm.pdf"
Dim theFieldIDs, theList
theFieldIDs = theDoc.GetInfo(theDoc.Root, "Field IDs")
theList = Split(theFieldIDs, ",")
For Each fieldID In theList
thePartialName = theDoc.GetInfo(fieldID, "/T:text")
theDoc.SetInfo fieldID, "/TU:text", thePartialName
Next
theDoc.Save "output.pdf"
theDoc.Clear
Changing "/TU:text"
to "/T:text"
will set a field's partial name.
Examples written in C# and VB.NET of the functions used can be found here: Doc.GetInfo, Doc.SetInfo. See also the documentation on Object Paths.