pdfSetNumberFormat
Give a text field Acrobat-standard numeric input formatting
BOOL32 __stdcall pdfSetNumberFormat(PPDF IPDF, uint32_t TxtField, int32_t Sep, uint32_t DecPlaces, int32_t NegStyle, const char* CurrStr, BOOL32 Prepend);
function pdfSetNumberFormat(const IPDF: PPDF; TxtField: Cardinal; Sep: Integer; DecPlaces: Cardinal; NegStyle: Integer; const CurrStr: PAnsiChar; Prepend: LongBool): LongBool; stdcall;
Purpose. Give a text field Acrobat-standard numeric input formatting by attaching AFNumber_Format/AFNumber_Keystroke JavaScript actions — the same mechanism Acrobat itself uses for its built-in "Number" field format, not an internal formatting enum applied at render time.
Description. Clamps Sep/NegStyle to [0..3] (silently resets to 0 if out of range — no error reported). Builds the standard AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, bPrepend) argument list (with currStyle hardcoded to 0 — the currency-style axis of Acrobat's own function is not independently exposed by this parameter set) and installs it as the field's /AA /F (format, on-blur) action, plus the matching AFNumber_Keystroke(...) as /AA /K (keystroke, on-input validation). CurrStr is JS-string-escaped ("/\) before embedding. CurrStr is ANSI-only — there is no W variant, so multi-byte/Unicode currency symbols cannot be set this way.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
TxtField | Target text field handle. |
Sep | Thousands-separator style, 0-3 (Acrobat convention); out-of-range silently becomes 0. |
DecPlaces | Decimal places. |
NegStyle | Negative-number display style, 0-3; out-of-range silently becomes 0. |
CurrStr | Currency symbol/string (ANSI only), always appended (never prepended-only or omitted) per Prepend. |
Prepend | True places CurrStr before the number, False after. |
Return value. True if TxtField resolves to a known field; False otherwise.
Remarks. Because this attaches real JavaScript actions, the formatting only takes visible effect in a JS-capable viewer (Acrobat/ Reader); viewers that ignore /AA show the raw field value unformatted.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Setters
pdfSetNumberFormat
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.