API reference › Rendering & Viewer
rasCopyToClipBoard
Real, substantial text-selection functionality: extract
const wchar_t* __stdcall rasGetSelectedText(IPGC CachePtr, uint32_t* Size);
BOOL32 __stdcall rasCopyToClipBoard(IPGC CachePtr, HWND hWnd, TSelectObjType SelectedObjType, uint32_t Flags);
BOOL32 __stdcall rasHighlightText(IPGC CachePtr, TAnnotType SubType, uint32_t Color, const wchar_t* Author);
function rasGetSelectedText(CachePtr: IPGC; var Size: Cardinal): PWideChar; stdcall;
function rasCopyToClipBoard(CachePtr: IPGC; hWnd: HWND; SelectedObjType: TSelectObjType; Flags: Cardinal): LongBool; stdcall;
function rasHighlightText(CachePtr: IPGC; SubType: TAnnotType; Color: Cardinal; const Author: PWideChar): LongBool; stdcall;
Purpose. Real, substantial text-selection functionality: extract the actual PDF text under the current marquee selection, copy it to the system clipboard, or convert it into a genuine markup annotation.
Description. rasGetSelectedText maps the device-pixel selection rectangle into the current page's PDF user space, parses the page's content stream via the SDK's own TPsrContentParser/ExtractRuns (decoding each text run's glyph IDs back to Unicode via D.DecodeGIDString), and keeps only runs whose baseline origin point falls within the selection rect (with a 1-unit tolerance) — this is an origin-point containment test, not a full glyph-bounding-box intersection, so a selection rectangle that clips through the middle of a glyph without containing its origin will not include that glyph's text. The result is cached into C.SelTextBuf. rasCopyToClipBoard reuses SelTextBuf if already populated, else calls rasGetSelectedText itself first, then writes it to the system clipboard via ViewerSetClipboardText (targeting hWnd, or the cache's own stored WndHandle if hWnd is 0) — SelectedObjType and Flags are both accepted by the ABI but not observed to affect this text-only clipboard path. rasHighlightText maps the selection to PDF space the same way, then genuinely creates a real markup annotation (AddMarkupAnnot) whose subtype is chosen from SubType (Underline/StrikeOut/Squiggly, defaulting to Highlight for any other value) — and, critically, also synthesizes its /AP /N appearance stream (CreateAnnotAPH) immediately, per an inline comment warning that without this step "the annotation carries only QuadPoints and never rasterizes." Author is narrowed through AnsiString(WideString(Author)) before storage — the same codepage narrowing pattern documented for other W-suffixed string parameters elsewhere in this SDK.
Parameters.
| Parameter | Description |
|---|---|
CachePtr | Target page cache. |
Size | *(GetSelectedText only)* Output: character count. |
hWnd | *(CopyToClipBoard only)* Target window for the clipboard operation; falls back to the cache's stored window handle if 0. |
SelectedObjType, Flags | *(CopyToClipBoard only)* Accepted; not observed to affect the (text-only) clipboard behavior. |
SubType | *(HighlightText only)* Markup kind; unrecognized values default to Highlight. |
Color | *(HighlightText only)* Annotation color. |
Author | *(HighlightText only)* Narrowed to system codepage before storage. |
Return value. rasGetSelectedText: the extracted text (transient buffer); nil if no selection or nothing matched. rasCopyToClipBoard/ rasHighlightText: True on success.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Rasterizer/Rendering
rasCopyToClipBoard
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.