Skip to content

FLUT-895412-[others][flutter]: Added sample to retrive actions from the PDF #1254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: hotfix/hotfix-v29.2.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Flutter/pdf/working-with-forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,32 @@ File('output.pdf').writeAsBytesSync(await document.save());

{% endhighlight %}

## Retrieving Actions from a Form Field

In PDF documents, form fields can have associated actions that dictate behavior when a user interacts with the field. You can retrieve these actions from a form field using the PdfFieldActions property. This property is read-only and provides the actions currently associated with a field.

The following code sample demonstrates how to retrieve actions from an existing form field in a PDF document.

{% highlight dart %}
// Load an existing PDF document.
final PdfDocument document =
PdfDocument(inputBytes: File('input.pdf').readAsBytesSync());

// Get the form field from which you want to retrieve actions.
final PdfButtonField buttonField = document.form.fields[0] as PdfButtonField;

// Retrieve and process the actions of the form field.
final PdfFieldActions actions = buttonField.actions;
// Check if actions are not null and perform a test.
if (actions != null) {
// Check for specific known action properties or behaviors.
print('Actions are present for the field.');
} else {
print('No actions associated with the field.');
}

{% endhighlight %}

## Filling form fields in an existing PDF Document

Flutter PDF allows you to fill the form fields using the PdfField class.
Expand Down