Docs PDFiumVCL

GetSelectedFormText method

Questa voce API conserva identificatori, firme, blocchi di codice e termini PDF nella forma originale.
Component: TPdfView  ·  Unit: PDFium
Returns the text currently selected inside the focused AcroForm widget on the view's active page.

Syntax

function GetSelectedFormText: WString;

Description

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:

In all three cases the return value is an empty string — the method never raises.

Remarks

Example

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;

See Also

SelectAllFormText, FormUndo, FormRedo, FormField