procedure GenerateFormAppearances;
GenerateFormAppearances rebuilds the /AP (Erscheinungsstrom-)Eintrag für jedes AcroForm-Widget auf allen Seiten des geladenen Dokuments. Dazu rendert es jede Seite durch die PDFium-Form-Fill-Engine (FPDF_FFLDraw), wodurch die aktuellen Feldwerte in die visuelle Darstellung des Widgets im PDF eingebrannt werden
This call is a mandatory companion to FormField[i] := value assignments. Without it, a form field's value is stored in the PDF's data dictionary but has no corresponding appearance stream. PDF viewers typically show the value only while the field has input focus; other viewers may show nothing at all. More critically, any call to FlattenPage or FlattenAllPages ohne vorherige Erzeugung der Erscheinungsbilder wird stillschweigend Ausgabe erzeugt, der die ausgefüllten Werte fehlen
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.
Die Prozedur arbeitet das gesamte Dokument in einem Aufruf ab; es gibt keine Variante pro Seite
begin
// Assign form field values
Pdf1.FormField[0] := 'Alice Example';
Pdf1.FormField[1] := 'alice@example.com';
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;