Class AddIndexStrategy

java.lang.Object
com.itextpdf.forms.fields.merging.AddIndexStrategy
All Implemented Interfaces:
OnDuplicateFormFieldNameStrategy

public class AddIndexStrategy extends Object implements OnDuplicateFormFieldNameStrategy
A OnDuplicateFormFieldNameStrategy implementation that adds an index to the field name of the second field
  • Constructor Details

    • AddIndexStrategy

      public AddIndexStrategy (String separator)
      Creates a new AddIndexStrategy instance.
      Parameters:
      separator - the separator that will be used to separate the original field name and the index
    • AddIndexStrategy

      public AddIndexStrategy()
      Creates a new AddIndexStrategy instance. The default separator will be used to separate the original field name and the index. the default separator is "_"
  • Method Details

    • execute

      public boolean execute (PdfFormField firstField, PdfFormField secondField, boolean throwExceptionOnError)
      Renames the second field by adding an index to its name.
      Specified by:
      execute in interface OnDuplicateFormFieldNameStrategy
      Parameters:
      firstField - the first field
      secondField - the second field
      throwExceptionOnError - if true, an exception will be thrown
      Returns:
      true if the second field was renamed successfully, false otherwise