unit MainForm;

{$I ..\..\..\Lib\PDFlibDefines.inc}

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.StdCtrls,
  PDFlibrary;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
Var
  i, FFC: Integer;
  FFS: String;
begin
  with TPDFlib.Create do
    try
      LoadFromFile('FormFieldOld.pdf', '');
      FFC := FormFieldCount;
      for i := 1 to FFC do
      begin
        FFS := GetFormFieldValue(i);
        SetFormFieldValue(i, FFS + ' New');
        SetNeedAppearances(0);
      end;
      SaveToFile('FormFieldNew.pdf');
    finally
      Free;
    end;
end;

end.
