Skip to main content

PdfAcroFormFieldNameCollision Struct

Represents a structure which stores information about a collision found in interactive form field names.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v24.1.Core.dll

NuGet Package: DevExpress.Pdf.Core

Declaration

public struct PdfAcroFormFieldNameCollision

Remarks

Field names must be unique within an interactive form.

To obtain the interactive form field in which a collision was found with a field name, use the PdfAcroFormFieldNameCollision.Field property.

You can also get the forbidden field names using the PdfAcroFormFieldNameCollision.ForbiddenNames property.

The code sample below checks whether the created fields’ names already exist in the loaded document and renames the conflicting field.

List<PdfAcroFormField> fields = new List<PdfAcroFormField>();
fields.Add(textBox);
fields.Add(radioGroup);
//Check whether new form fields' names already exist in the document
IList<PdfAcroFormFieldNameCollision> collisions = processor.CheckFormFieldNameCollisions(fields);
if (collisions.Count == 0)
    Console.WriteLine("No name conflicts are detected");
else
{
    foreach (var collision in collisions)
    {
        //Rename conflicting field
        Console.WriteLine("The specified form field name ({0}) already exist in the document. Renaming...", collision.Field.Name);
        while (collision.ForbiddenNames.Contains(collision.Field.Name))
            collision.Field.Name = Guid.NewGuid().ToString();
    }
}
//Add fields to the document
//And save the result
processor.AddFormFields(fields);
processor.SaveDocument("Result.pdf");
See Also