PDFium Delphi Component Docs

CopySelectionToClipboard function

Component: TPdfView  ·  Unit: PDFium
Places the current Unicode text selection on the system clipboard

Syntax

function CopySelectionToClipboard: Boolean;

Description

On Windows, obtains the selection through SelectedText and places it on the clipboard as CF_UNICODETEXT, using OpenClipboard / EmptyClipboard / GlobalAlloc / SetClipboardData; success returns True

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 allows 100ms of limited retries for transient contention without pumping UI messages; access still unavailable at the end returns False

Native Free Pascal/LCL on Linux and macOS converts the component's UTF-16 selection for the widget set's UTF-8 clipboard API; Windows alone uses the clipboard retry allowance, and native access needs a working desktop clipboard service

Remarks

Example

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

See Also

SelectedText, HasSelection, SelectAll, ClearSelection