officefileapi-devexpress-dot-pdf-55760e36.md
Represents a structure which stores information about a collision found in interactive form field names.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public struct PdfAcroFormFieldNameCollision
Public Structure PdfAcroFormFieldNameCollision
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");
Dim fields As New List(Of PdfAcroFormField)()
fields.Add(textBox)
fields.Add(radioGroup)
'Check whether new form fields' names already exist in the document
Dim collisions As IList(Of PdfAcroFormFieldNameCollision) = processor.CheckFormFieldNameCollisions(fields)
If collisions.Count = 0 Then
Console.WriteLine("No name conflicts are detected")
Else
For Each collision In collisions
'Rename conflicting field
Console.WriteLine("The specified form field name ({0}) already exist in the document. Renaming...", collision.Field.Name)
Do While collision.ForbiddenNames.Contains(collision.Field.Name)
collision.Field.Name = Guid.NewGuid().ToString()
Loop
Next collision
End If
'Add fields to the document
'And save the result
processor.AddFormFields(fields)
processor.SaveDocument("Result.pdf")
See Also