Skip to content

Inconsistency when iterating over a PdfAcroFieldCollection #269

@SabinPop

Description

@SabinPop

Hi,
This is not really a bug, rather an inconsistency.

Expected Behavior

Accessing the collection using the enumerator should return the same type as accessing it using the index.

Actual Behavior

  • Accessing elements of a PdfAcroFieldCollection using the index will return the element as PdfAcroField.
  • Using the enumerator will return the element as PdfItem.

The issue is that there is no way to convert the PdfItem to PdfAcroField since the method used for the conversion is not accessible and PdfAcroField subtypes' constructor are internal.

Steps to Reproduce the Behavior

Compare iterating over the collection using a for loop and a foreach loop. The variable item has a different type.

for (int i = 0; i < acroFieldCollection.Count; i++) {
    PdfAcroField item = acroFieldCollection[i];
    // do something with the item
}
foreach (PdfItem item in acroFieldCollection) {
    // do something with the item 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions