InsertPageElementClipPath
Content stream editing, Clipping paths
Description
Adds a non-zero or even-odd clipping path that affects only one exact enumerated text, image or path element
Syntax
Delphi
Function TPDFlib.InsertPageElementClipPath(ElementID: Integer; Const PathSource: WideString; FillRule: Integer): Integer;Parameters
| ElementID | Opaque page-element handle returned by EnumPageElements or EnumeratePageElements |
|---|---|
| PathSource | Path-construction instructions only, beginning with m or re and excluding W, W* and path-painting operators |
| FillRule | 0 for the non-zero winding rule or 1 for the even-odd rule |
Return values
| 1 | The local clipping path was inserted and all page-element handles were invalidated |
|---|---|
| 0 | The handle or path source is invalid, the handle is stale or the text state cannot be reconstructed safely |
Remarks
The method writes a balanced q/Q scope around the target so the new intersection cannot leak into following page content
PathSource coordinates use the current user space at the target; enumerated clipping segments and bounds use default user space after the active CTM
For a target inside a text object, the method creates valid surrounding text objects and replays the original invisible advance so text extraction and later positioning remain unchanged
Text rendering modes that contribute glyph outlines to clipping are read-only because isolating them would change persistent clip semantics
On failure, inspect LastErrorCode: 532 means invalid input, 533 means stale content and 534 means the target cannot be edited safely