PDFium Delphi Component Docs

GenerateFormAppearances method

Component: TPdf  ·  Unit: PDFium
Regenerates the /AP (appearance stream) for every form widget on every page by rendering each page through FPDF_FFLDraw. This is the recommended companion call to FormField[i] := value assignments — without it, form values may be visible only when the field has focus, and any subsequent flatten operation will silently lose the values. Call after all FormField[] assignments and before SaveAs / FlattenPage / FlattenAllPages

Syntax

procedure GenerateFormAppearances;

Description

GenerateFormAppearances rebuilds editable text and combo-box appearances through the native form-fill editor and synchronizes checkbox and radio-button appearance states

Native text and combo-box assignments commit their appearance through the form-fill editor; raw dictionary edits and initially missing appearances can still require this regeneration step before flattening, which uses stored appearance streams rather than the live editor's display

The correct workflow when filling and locking a form is: assign all FormField[] values → call GenerateFormAppearances once → optionally call FlattenPage / FlattenAllPages → call SaveAs. If you only need to save the filled form without flattening, GenerateFormAppearances is still recommended to ensure maximum compatibility with third-party PDF viewers

The procedure operates on the entire document in one call; there is no per-page variant

Example

begin
  // Assign form field values
  Pdf1.FormField[0] := 'Alice Example';
  Pdf1.FormField[1] := '[email protected]';
  Pdf1.FormField[2] := '2026-05-20';
  
  // Bake appearance streams so values are visible in all viewers
  Pdf1.GenerateFormAppearances;
  
  // Flatten and save a non-editable copy
  Pdf1.FlattenAllPages;
  Pdf1.SaveAs('output_filled_flat.pdf');
end;

Inherited widgets use a temporary native edit followed by a verified restoration of the original parent-field value; no shadow value is written to the widget

Inherited read-only fields cannot use this editing workflow and raise an error; GenerateFormAppearances is not a transactional document operation

See Also

FlattenPage, FlattenAllPages, FormField, SaveAs