function GetSelectedFormText: WString;
GetSelectedFormText is a high-level entry point on top of PDFium's
FORM_GetSelectedText binding. The PDFium API was already
bound at the unit level but had no Pascal-friendly accessor until
v1.23.0; this method wraps it cleanly.
The method targets whatever AcroForm widget currently owns the focus on the view's active page (the same widget that responds to keyboard input). When the user has selected a range of characters inside that widget — for example by Shift+Arrow or click-and- drag — GetSelectedFormText returns the selection text as a WString. When no text is selected (just a caret position), GetSelectedFormText returns an empty string.
The method is a no-op when:
Active = False);FormType = ftNone);In all three cases the return value is an empty string — the method never raises.
SelectAllFormText to support a "Select All" menu item, then use GetSelectedFormText to feed the selection to Clipboard.AsText.FormField[i] := ... may collapse the selection back to a caret.
procedure TForm1.btnCopyClick(Sender: TObject);
var
S: WString;
begin
S := PdfView1.GetSelectedFormText;
if S <> '' then
Clipboard.AsText := string(S)
else
ShowMessage('No form text selected');
end;