Guide
How to inspect PDF push-button actions in C#
Load the AcroForm, filter terminal fields to PushButtonFormField, then read caption and action
metadata.
ZingPDF exposes action dictionaries as metadata. It does not execute click behavior because execution belongs to PDF viewers and editing software.
Enumerate push buttons
GetFieldsAsync() returns terminal fields. Use LINQ type filtering to find push buttons.
using ZingPDF;
using ZingPDF.Elements.Forms.FieldTypes.Button;
using var pdf = Pdf.Load(File.OpenRead("form.pdf"));
var form = await pdf.GetFormAsync();
if (form is null)
{
return;
}
foreach (var button in (await form.GetFieldsAsync()).OfType())
{
var caption = await button.GetCaptionAsync();
Console.WriteLine($"{button.Name}: {caption}");
}
Read action metadata
A push button can expose a primary action dictionary. The high-level wrapper reports common action metadata without executing the action.
var button = await form.GetFieldAsync("Submit");
if (button is not null && await button.HasActionAsync())
{
var actionType = await button.GetActionTypeAsync();
var uri = await button.GetActionUriAsync();
var namedAction = await button.GetNamedActionAsync();
Console.WriteLine($"Action type: {actionType}");
Console.WriteLine($"URI: {uri}");
Console.WriteLine($"Named action: {namedAction}");
}
Additional actions
Additional-action dictionaries are keyed by trigger names such as mouse, focus, blur, or page-state events. ZingPDF reports the trigger keys present on the field or its widgets.
var button = await form.GetFieldAsync("Submit");
if (button is null)
{
return;
}
var triggers = await button.GetAdditionalActionTriggersAsync();
foreach (var trigger in triggers)
{
Console.WriteLine(trigger);
}
Scope
GetCaptionAsync()reads the field or widget caption when present.GetActionTypeAsync()returns the primary action/Sname.GetActionUriAsync()returns a target only for primary URI actions.GetNamedActionAsync()returns a value only for primary named actions.- The library does not submit forms, open URLs, reset forms, or run JavaScript.
Next step
For ordinary field filling, see How to fill PDF form fields in C#.