Table of Contents

Class PdfFormScripts

Namespace
PdfEngine.Vector.Forms
Assembly
PdfEngine.Vector.dll

The standard Acrobat form functions (AFNumber_, AFPercent_, AFDate_, AFTime_, AFSpecial_*, AFRange_Validate, AFSimple_Calculate and simplified field notation), recognised in a field's scripts and carried out natively. Document JavaScript is never executed: a script that is anything more than these calls is reported as unsupported.

public static class PdfFormScripts
Inheritance
PdfFormScripts
Inherited Members

Methods

Accept(PdfFieldBehavior, string)

A value typed into the field, checked as its keystroke and validate scripts would on commit: the value to store, or why it is refused.

public static (string? Value, string? Error) Accept(PdfFieldBehavior b, string input)

Parameters

b PdfFieldBehavior
input string

Returns

(string Value, string Error)

AllowsCharacter(PdfFieldBehavior, char)

Whether a character may be typed into the field (its keystroke script's rule).

public static bool AllowsCharacter(PdfFieldBehavior b, char c)

Parameters

b PdfFieldBehavior
c char

Returns

bool

Canonical(decimal)

A number as JavaScript would print it, but exact: no trailing zeros, no binary noise.

public static string Canonical(decimal d)

Parameters

d decimal

Returns

string

Display(PdfFieldBehavior, string)

The field's value as it shows: formatted by its format script, or as it is.

public static PdfFieldDisplay Display(PdfFieldBehavior b, string value)

Parameters

b PdfFieldBehavior
value string

Returns

PdfFieldDisplay

FormatDate(DateTime, string)

public static string FormatDate(DateTime d, string pattern)

Parameters

d DateTime
pattern string

Returns

string

FormatNumber(decimal, int, int)

public static string FormatNumber(decimal value, int decimals, int separatorStyle)

Parameters

value decimal
decimals int
separatorStyle int

Returns

string

ParseDate(string, string)

A date typed in any reasonable way, read in the order the pattern puts day, month and year (AFParseDateEx).

public static DateTime? ParseDate(string text, string pattern)

Parameters

text string
pattern string

Returns

DateTime?

ParseNumber(string, int)

A number as typed or stored: invariant first, then by the field's separator style (AFMakeNumber).

public static decimal? ParseNumber(string text, int separatorStyle = 0)

Parameters

text string
separatorStyle int

Returns

decimal?

Prepare(PdfAcroForm, IEnumerable<PdfFieldChange>)

The changes to write for what the user entered: each typed value checked by the field's keystroke and validate rules (a refusal throws), stored in its canonical form and shown through its format; then every calculated field recalculated, in calculation order, and formatted the same way. Fields whose scripts are custom code are filled as typed.

public static List<PdfFieldChange> Prepare(PdfAcroForm form, IEnumerable<PdfFieldChange> changes)

Parameters

form PdfAcroForm
changes IEnumerable<PdfFieldChange>

Returns

List<PdfFieldChange>

Read(PdfFormField)

public static PdfFieldBehavior Read(PdfFormField field)

Parameters

field PdfFormField

Returns

PdfFieldBehavior

Recalculate(PdfAcroForm, IReadOnlyDictionary<string, string>)

Recalculates every calculated field in calculation order, each seeing the results of the ones before it. Returns the fields whose value changed, with the new value.

public static IReadOnlyList<(string Field, string Value)> Recalculate(PdfAcroForm form, IReadOnlyDictionary<string, string> values)

Parameters

form PdfAcroForm
values IReadOnlyDictionary<string, string>

Returns

IReadOnlyList<(string Export, string Display)>