AcroForm field flag precision
The PDF field flag entry /Ff is a 32-bit mask whose high bits and low common flags are preserved together by native field creation, editing, saving and reloading
A high bit does not erase ReadOnly, Required or NoExport through floating-point rounding
Integer values represent the same 32 bits
The public native APIs continue to use signed Integer values, with their existing declarations and calling conventions
A mask with bit 31 set has a negative Integer representation: $80000002 and -2147483646 represent the same bits, including Required
| Common flag | Mask | Meaning |
|---|---|---|
ReadOnly | 1 | The field is read-only for interactive form filling |
Required | 2 | The field requires a value for form submission |
NoExport | 4 | The field is excluded from exported form data |
Use the relevant PDF field-type flags for the intended behaviour; exact bit preservation does not assign a new meaning to reserved bits
var
Bits: Cardinal;
NativeFlags: Integer;
begin
Bits := $80000002;
Move(Bits, NativeFlags, SizeOf(NativeFlags));
PDF.SetLoadedFormFieldFlags(FieldIndex, NativeFlags);
NativeFlags := PDF.GetLoadedFormFieldFlags(FieldIndex);
Move(NativeFlags, Bits, SizeOf(Bits));
// Bits is still $80000002, including Required
end;
Loaded fields and inheritance
GetLoadedFormFieldFlags reads the effective mask from the selected field and its ancestors
An absent /Ff or a local /Ff null continues the parent lookup; a numeric zero is an explicit zero mask
Reading an inherited mask leaves the child dictionary unchanged, whilst SetLoadedFormFieldFlags replaces the complete mask with a local entry on the selected field
The loaded ReadOnly and Required shortcuts start from the effective inherited mask, toggle their own bit and retain the remaining bits without changing the ancestor or a sibling
Both the index and name overloads of SetFormFieldReadOnly preserve the remaining mask in the same way
A recognised PDF null token is consumed at its own boundary, so reading a null field entry does not merge keys or values from the following indirect object
Native creation and fluent builders
CreateLoadedFieldWidget preserves the complete Integer mask supplied as AFlags when it creates the field dictionary
The page field constructors retain the exact mask assembled from their existing THPDFFormFieldFlags argument
THPDFAcroFormField keeps its existing local-dictionary behaviour: SetReadOnly, SetRequired and SetNoExport toggle one local bit and return the same builder
Builder operations keep their field and widget targets, including the existing division between radio-group parent flags and child widget flags
Saving and reopening the resulting PDF retains the exact integer mask rather than a rounded floating-point approximation
Existing local flag consumers
AddLoadedRadioButton reads an existing radio parent's local numeric /Ff as an exact mask, including unsigned high-bit source tokens, before appending another widget to that same group
Appending a widget does not rewrite the existing parent's flag token or copy its flags into a new local child entry
GenerateTextFieldAP is an existing protected helper for authored text appearances, also used internally by public text-field creation when automatic appearances are enabled
Exact reads preserve the existing Radio and Password bits when rounding the surrounding mask would otherwise carry into a higher bit: $8000FFFF must retain Radio, and $80003FFF must retain Password and Multiline
These examples preserve the known flags without assigning new meanings to other bits in the mask
The authored appearance helper keeps its local-only lookup, so an absent local flag entry is not replaced with inherited parent flags
These two consumers retain their existing numeric fallback when no usable integer source token is available; API declarations, radio-group targets and appearance flag meanings remain unchanged
Structured JSON and XML export
ExportLoadedPagesStructured uses the exact effective field mask when it builds the shared form-control model for structured output
The existing JSON flags, readOnly and required members and XML flags, read-only and required attributes retain their schema and meanings
A signed output integer retains the same 32-bit mask; the export does not add a separate NoExport property
Exact reads keep the existing payload rules accurate: 16777219 retains Comb, ReadOnly and Required without gaining NoExport, while 16777223 also retains NoExport
Those neighbouring masks must not become 16777220 or 16777224 through Single rounding, which would change the common flag bits and the existing value-suppression decision
An absent local /Ff, a direct null or a reference resolving to null continues the bounded parent lookup; an explicit numeric zero overrides the parent mask
A usable original integer token is read exactly, whilst a real token or an invalidated token retains the existing numeric rounding fallback
The export leaves source field dictionaries, values and flags unchanged; see structured loaded-page export for the existing password, file-select, NoExport and signature payload boundaries