List internal names from the included shipping.pdf: shipping.city, not “City”.
dotnet add package RecursiveAI.OnePdfRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
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, 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.
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.
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);
shipping.city shipping.note orderId
Variations
List the parent groups as well. In the snippet at the top, replace the loop with:
foreach (var field in form.AllFields) Console.WriteLine(field.FullName);
shipping shipping.city shipping.note orderId
Read one field by its full name. Replace the loop with:
var city = form.FindField("shipping.city"); Console.WriteLine(city?.Value ?? "(no value)");
PortlandRelated recipes
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, 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.