Advanced AcroForm Processing
HotPDF can recalculate loaded fields, regenerate standards-based variable-text appearances, resolve annotation appearance states, and flatten a selected field set without rewriting untouched pages
Calculation order
RecalculateLoadedFormFields follows the loaded /AcroForm /CO array and evaluates the bounded AFSimple_Calculate operations SUM, AVG, PRD, MIN, and MAX through the safe field-script evaluator
ApplyLoadedFieldCalculation installs the calculation action and adds the target field to /CO without duplicate entries
Safe field scripts
EvaluateLoadedFieldJavaScript evaluates only declarative calculation and validation statements associated with the requested field trigger
- Numeric expressions can use field values,
event.value, arithmetic, and a bounded set ofMathfunctions AFRange_Validateand explicitevent.rcliterals provide deterministic validation outcomes- Loops, dynamic evaluation, application access, submission, import, launch, and other active content are rejected
- Script length, statement count, parser depth, arguments, and operations have fixed upper bounds
Variable-text appearances
EnsureLoadedFieldAppearanceStream walks every widget and inherits /DA, /Q, /V, /DV, /Ff, and /MaxLen values from the field hierarchy or AcroForm
- Left, centre, and right quadding use the widget's local appearance coordinates
- Multiline text receives bounded line placement and clipping
- A zero default-appearance font size triggers automatic sizing
- Comb fields place each character independently across
/MaxLencells
Annotation appearance states
GetLoadedAnnotationAppearanceStream resolves normal, rollover, or down appearances and falls back from rollover or down to normal
State dictionaries use /AS, inherited /V or /DV, parent state, /Off, and sole-stream fallback in that order
Selective flattening
FlattenLoadedFormFields paints only selected widget appearances into their owning pages, removes only the matching fields and annotations, and retains every untouched page and field
The default permission gate refuses structural changes under DocMDP and enforces FieldMDP All, Include, and Exclude locks before any page is modified
PDF.BeginIncrementalUpdate('SignedForm.pdf');
PDF.RecalculateLoadedFormFields;
PDF.FlattenLoadedFormFields(['Subtotal', 'Total']);
PDF.SaveIncrementalUpdate('SignedForm-updated.pdf');