PDFium Delphi Component Docs

GetSelectedFormText method

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 tidily

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 each of these cases the return value is an empty string — the method never raises

Remarks

Example

procedure TForm1.btnCopyClick(Sender: TObject);
begin
  if not PdfView1.CopySelectedFormTextToClipboard then
    ShowMessage('No form text selected');
end;

See Also

CopySelectedFormTextToClipboard, SelectAllFormText, FormUndo, FormRedo, FormField