---
title: "List PDF AcroForm field names in C#"
url: https://recursiveai.org/onepdf/cookbook/read-pdf-form-field-names/
description: "List fully qualified PDF AcroForm field names in C#. Read nested field names without editing the values, and use them to look up individual fields."
version: "1.25.1"
---

# List PDF AcroForm field names in C#

**OnePDF** is a free, open-source PDF library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OnePdf) · [GitHub](https://github.com/recursive-ai-oss/onepdf-csharp) · [Docs](https://recursiveai.org/onepdf/docs/) · [Download example (.zip)](https://recursiveai.org/onepdf/cookbook/read-pdf-form-field-names/read-pdf-form-field-names.zip)

List internal names from the included `shipping.pdf`: `shipping.city`, not “City”.

```shell
dotnet add package RecursiveAI.OnePdf
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using System;
using OnePdf;
using var doc =
    PdfDocument.Open("shipping.pdf");
if (doc.Form is not { } form) return;
foreach (var field in form.TerminalFields)
    Console.WriteLine(field.FullName);
```

Unzip [the example](https://recursiveai.org/onepdf/cookbook/read-pdf-form-field-names/read-pdf-form-field-names.zip), then `dotnet run`.

A terminal field has no child fields and is the one that holds a value.

Prints the names of fields you can look up. It doesn’t change the PDF.

```text
shipping.city
shipping.note
orderId
```

## The full program

Run `dotnet run -- your-form.pdf` to list names in another PDF. The download prints `No AcroForm.` if the file has no AcroForm, as is often the case with scans.

```csharp
using System;
using OnePdf;

string path = args.Length == 0 ? "shipping.pdf" : args[0];
using var doc = PdfDocument.Open(path);
if (doc.Form is not { } form)
{
    Console.WriteLine("No AcroForm.");
    return;
}

foreach (var field in form.TerminalFields)
    Console.WriteLine(field.FullName);
```

```text
shipping.city
shipping.note
orderId
```

## Variations

**List the parent groups as well.** In the snippet at the top, replace the loop with:

```csharp
foreach (var field in form.AllFields)
    Console.WriteLine(field.FullName);
```

```text
shipping
shipping.city
shipping.note
orderId
```

**Read one field by its full name.** Replace the loop with:

```csharp
var city = form.FindField("shipping.city");
Console.WriteLine(city?.Value ?? "(no value)");
```

```text
Portland
```

## Related recipes

- [Fill a PDF form](https://recursiveai.org/onepdf/cookbook/fill-pdf-form/)
- [Reset PDF fields to their defaults](https://recursiveai.org/onepdf/cookbook/reset-pdf-form-fields-to-default/)
- [Rename a PDF form field](https://recursiveai.org/onepdf/cookbook/rename-pdf-form-field-and-set-appearance/)

## The short answer

Open the PDF read-only, loop through `doc.Form.TerminalFields`, and print each field’s `FullName`. AcroForm is PDF’s interactive field model. A terminal field is a field with no child fields, rather than a group used to organize other fields. The program prints the full names without reading or setting their values.

## How do I see PDF form field names?

Use the AcroForm tree rather than extracting visible text from the page. In the sample, the page says “Delivery note,” but the field’s partial name is `note` and its full name is `shipping.note`. OnePDF builds `FullName` by joining the nonempty partial names from the root with dots. The displayed label is not part of that calculation. If a PDF has a second `city` under `billing`, `shipping.city` and `billing.city` identify different fields.

Use `TerminalFields` when you want field IDs for a data map, `AllFields` when you also want the groups, and `Fields` when you need only the top level. `AllFields` visits each parent before its children. A field can have more than one widget (a control on the page), so counting the visible boxes need not give you the number of named fields. Listing the form tree reports the field, not a separate name for each box.

## How do I auto-populate a fillable PDF?

Start by listing the names in the exact template your code will fill. Pass a full name to `FindField` to check that a name in your data map still exists; it returns `null` when the name isn’t found. For read-only inspection, you don’t need to enable editing. When you do fill a field, use the complete name with the [form filling API](https://recursiveai.org/onepdf/docs/forms/#filling), not just its last segment or a label copied from the page. If the template author renames a group, the full names of its children change too.

A scanned form has no AcroForm names unless someone adds interactive fields. An XFA form is a different kind of form; OnePDF can expose XFA packets as bytes but doesn’t interpret them. If a PDF also contains AcroForm fields, the list covers those fields only.
