Skip to main content

PdfDocumentProcessor.CheckFormFieldNameCollisions(PdfAcroFormField[]) Method

Checks interactive form fields to find a collision in the form field names.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v23.2.dll

NuGet Package: DevExpress.Document.Processor


public IList<PdfAcroFormFieldNameCollision> CheckFormFieldNameCollisions(
    params PdfAcroFormField[] fields


Name Type Description
fields PdfAcroFormField[]

A PdfAcroFormField array of interactive form fields to check.


Type Description

A collection of PdfAcroFormFieldNameCollision objects that contains information about a collision found in interactive form field names.


When you create an intercative form field, make sure that its name is unique. Otherwise, a conflict might occur. The CheckFormFieldNameCollisions method allows you to check whether the form field’s name already exist in the document.

Use the CheckFormFieldNameCollisions method when you add a new form field to the loaded document.

The PdfAcroFormFieldNameCollision.Field property provides access to the conflicting form field.

Use the PdfAcroFormFieldNameCollision.ForbiddenNames property retrieve the collection of conflicting names.

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>();
//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");
    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
See Also