Package com.itextpdf.forms.fields
Class PdfFormFieldMergeUtil
java.lang.Object
com.itextpdf.forms.fields.PdfFormFieldMergeUtil
Utility class to merge form fields
PdfFormField
with the same names.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Gets partial name for the field dictionary.static void
mergeKidsWithSameNames
(PdfFormField parentField, boolean throwExceptionOnError) This method merges all kids with the same names for the given parent field dictionary (recursively).static boolean
mergeTwoFieldsWithTheSameNames
(PdfFormField firstField, PdfFormField secondField, boolean throwExceptionOnError) This method merges different values from two field dictionaries into the first one and combines kids.static void
processDirtyAnnotations
(PdfFormField parentField, boolean throwExceptionOnError) Sometimes widgets contain field related keys, and they are the same as these field keys at parent.
-
Method Details
-
mergeKidsWithSameNames
This method merges all kids with the same names for the given parent field dictionary (recursively).- Parameters:
-
parentField
- a field whose kids should be checked and merged in case of same partial names. -
throwExceptionOnError
- true if the exception is expected after the merge failed, false if log is expected.
-
mergeTwoFieldsWithTheSameNames
public static boolean mergeTwoFieldsWithTheSameNames(PdfFormField firstField, PdfFormField secondField, boolean throwExceptionOnError) This method merges different values from two field dictionaries into the first one and combines kids.- Parameters:
-
firstField
- a field into which dictionary all values will be merged. -
secondField
- a field whose values should be merged into the first dictionary. -
throwExceptionOnError
- true if the exception is expected after the merge failed, false if log is expected. - Returns:
- true if fields is successfully merged, false otherwise.
-
getPartialName
Gets partial name for the field dictionary.- Parameters:
-
field
- field to get name from. - Returns:
- field partial name. Also, null if passed dictionary is a pure widget, empty string in case it is a field with no /T entry.
-
processDirtyAnnotations
public static void processDirtyAnnotations(PdfFormField parentField, boolean throwExceptionOnError) Sometimes widgets contain field related keys, and they are the same as these field keys at parent. During merge process we get something like: ParentField(/DA
Field/Ft /T /Kids ) -> (/DA
Annotation (without any form fields)/Kids ) -> This method combines ParentField with Field.
- Parameters:
-
parentField
- a field whose form field kids should be checked and merged with parent in case all their dictionary values (except Parent and Kids) are the same or parent is a radio button. -
throwExceptionOnError
- true if the exception is expected after the merge failed, false if log is expected.
-