PdfFormScriptSession Class
Runs the scripts of an interactive form (ISO 32000-2, 12.6.4.17, 12.7.6) in a sandbox, when the host sets values: the keystroke and validation scripts of the field set, then the calculation scripts of the form in their order (PdfInteractiveForm.CalculationOrder), then the format scripts of the fields that changed.
public sealed class PdfFormScriptSession : IDisposableRemarks
The scripts never run implicitly: opening a document and setting PdfFormField.Value run none. The document-level scripts (PdfDocument.JavaScripts) run once, when the session is created; the open action never runs.
The scripts run in a realm of their own, with the limits of the options. They see the event object, the fields (this.getField), the AF functions of the viewers (AFSimple_Calculate, AFNumber_Format...), util.printf, util.printd, util.scand and app.alert. The functions that reach outside of the form (submit, mail, print, open a URL or a document, menu items) do nothing, and are reported in the diagnostics. The numbers and the dates are formatted with fixed rules, not with the culture of the process.
- Implements
Properties
| Name | Description |
|---|---|
| InitializationDiagnostics | Gets the diagnostics of the document-level scripts, run when the session was created. |
InitializationDiagnostics
PdfFormScriptSession.csGets the diagnostics of the document-level scripts, run when the session was created.
public IReadOnlyList<PdfFormScriptDiagnostic> InitializationDiagnostics { get; }Property value
Methods
| Name | Description |
|---|---|
| Dispose() | Releases the engine of the scripts. |
| Recalculate() | Runs the calculation scripts of the form in their order, then the format scripts of the fields that changed. |
| SetValue(string, string?) | Sets the value of a field as a user would commit it: the keystroke and validation scripts of the field may reject it, then the calculation scripts of the form run, then the format scripts of the fields that changed. |
| SetValues(IEnumerable<KeyValuePair<string, string?>>) | Sets the values of several fields: the keystroke and validation scripts of each, then the calculation scripts of the form once, at the end, then the format scripts of the fields that changed. |
Dispose()
PdfFormScriptSession.csReleases the engine of the scripts.
public void Dispose()Recalculate()
PdfFormScriptSession.csRuns the calculation scripts of the form in their order, then the format scripts of the fields that changed.
public PdfFormScriptResult Recalculate()Returns
PdfFormScriptResult The fields that changed, and the diagnostics of the scripts.
Exceptions
PdfFormScriptException- A script failed, and
PdfFormScriptOptions.ThrowOnScriptErroris set.
SetValue(string, string?)
PdfFormScriptSession.csSets the value of a field as a user would commit it: the keystroke and validation scripts of the field may reject it, then the calculation scripts of the form run, then the format scripts of the fields that changed.
public PdfFormScriptResult SetValue(string fullName, string? value)Parameters
Returns
PdfFormScriptResult Whether the value was accepted, the fields that changed, and the diagnostics of the scripts.
Exceptions
ArgumentException- The form has no field of this name.
PdfFormScriptException- A script failed, and
PdfFormScriptOptions.ThrowOnScriptErroris set.
SetValues(IEnumerable<KeyValuePair<string, string?>>)
PdfFormScriptSession.csSets the values of several fields: the keystroke and validation scripts of each, then the calculation scripts of the form once, at the end, then the format scripts of the fields that changed.
public PdfFormScriptResult SetValues(IEnumerable<KeyValuePair<string, string?>> values)Parameters
valuesIEnumerable<KeyValuePair<string, string?>>- The values, by fully qualified name of field.
Returns
PdfFormScriptResult Whether every value was accepted, the fields that changed, and the diagnostics of the scripts.
Exceptions
ArgumentException- The form has no field of one of the names.
PdfFormScriptException- A script failed, and
PdfFormScriptOptions.ThrowOnScriptErroris set.