This is described in the source code for iText (Sharp):
virtual public bool RenameField(String oldName, String newName)
Thus, using this method, you can rename First.Name to First.NameOrEmpty or something like that, but not to EmptyOrFirst.Name .
The background is that the form fields in PDF files are not just ordered as a list of objects with a full name, but instead as a tree in which the full name of the node is a concatenation of the partial names of its ancestors and the node itself is separated by dots.
Thus, changing anything other than the part after the last point (or changing this part, but introducing a new point) actually means moving the field in the tree to another parent node, which may or may not be created in the process.
The RenameField method, on the other hand, only supports changing the local name of the field tree element itself.
And that is reasonable. Form fields can inherit a number of properties from their parent. So, if you rename a field, do you want the result field to inherit from the new parent? Or will all inherited properties be explicitly added to node? Or only those that are different from the corresponding new legacy information? Or do you have another idea?
source share