API referenceForms

pdfSetNumberFormat

Give a text field Acrobat-standard numeric input formatting

C
BOOL32 __stdcall pdfSetNumberFormat(PPDF IPDF, uint32_t TxtField, int32_t Sep, uint32_t DecPlaces, int32_t NegStyle, const char* CurrStr, BOOL32 Prepend);
Delphi
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.

ParameterDescription
IPDFDocument handle.
TxtFieldTarget text field handle.
SepThousands-separator style, 0-3 (Acrobat convention); out-of-range silently becomes 0.
DecPlacesDecimal places.
NegStyleNegative-number display style, 0-3; out-of-range silently becomes 0.
CurrStrCurrency symbol/string (ANSI only), always appended (never prepended-only or omitted) per Prepend.
PrependTrue 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)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Forms
Category

Setters

Exported names

pdfSetNumberFormat

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.