Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PdfAcroFormFieldNameCollision Struct

In This Article

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

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v24.2.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