PDFium Delphi Component Docs

CopySelectionToClipboard function

Component: TPdfView  ·  Unit: PDFium
Copies the currently selected Unicode text to the system clipboard

Syntax

function CopySelectionToClipboard: Boolean;

Description

On Windows, pulls the current selection through SelectedText and writes it onto the clipboard as CF_UNICODETEXT via OpenClipboard / EmptyClipboard / GlobalAlloc / SetClipboardData. Returns True on success

Returns False when there is no selection to copy, when SelectedText resolves to the empty string, or when a Win32 clipboard call fails, including memory allocation or unavailable access

Since v3.126.0, Windows clipboard opening uses a bounded 100ms retry budget for transient contention without pumping UI messages; access that remains unavailable still returns False

Native Free Pascal/LCL on Linux and macOS uses the widget set's UTF-8 text clipboard interface and converts from the component's UTF-16 selection. The Windows clipboard retry budget applies only to the Windows implementation; native clipboard access requires an available desktop clipboard service

Remarks

Example

if not PdfView1.CopySelectionToClipboard then
  ShowMessage('Nothing selected, or clipboard unavailable.');

See Also

SelectedText, HasSelection, SelectAll, ClearSelection