API referenceGraphics

pdfBeginPattern

Begin/end capturing a custom tiling pattern — drawing

C
int32_t __stdcall pdfBeginPattern(PPDF IPDF, TPatternType PatternType, TTilingType TilingType, double Width, double Height);
BOOL32 __stdcall pdfEndPattern(PPDF IPDF);
Delphi
function pdfBeginPattern(const IPDF: PPDF; PatternType: TPatternType; TilingType: TTilingType; Width, Height: Double): Integer; stdcall;
function pdfEndPattern(const IPDF: PPDF): LongBool; stdcall;

Purpose. Begin/end capturing a custom tiling pattern — drawing commands issued between pdfBeginPattern and pdfEndPattern are recorded into the pattern's own content, not the current page.

Description. pdfBeginPattern creates a fresh scratch TLumasPdfPage sized Width x Height (values <= 0 default to 1) as the pattern's tile-content surface, registers a new pattern entry (auto-allocated handle, alias PtN), stores PaintType (1=colored, 2=uncolored — any PatternType value other than 2 becomes 1) and TilingType + 1 (the PDF /TilingType value: 1=constant spacing, 2=no distortion, 3=fast constant spacing — TilingType's own 0-based ordinal is shifted by one), and pushes the current capture surface onto an internal capture stack, redirecting subsequent drawing calls into the new pattern surface. pdfEndPattern is a thin wrapper over the same generic EndCapture used by pdfEndTemplate (see the templates cluster) — it pops the capture stack back to whatever surface was active before pdfBeginPattern, failing if no capture is currently open (capture depth <= 0).

Parameters.

ParameterDescription
IPDFDocument handle.
PatternType1=colored (drawn colors are used as-is), other values normalize to colored; 2=uncolored (only shapes matter, color supplied at apply-time).
TilingType0=constant spacing, 1=no distortion, 2=fast constant spacing (PDF /TilingType = this + 1).
Width, HeightTile bounding-box size; values <= 0 default to 1.

Return value. pdfBeginPattern: the new pattern handle (always succeeds — no failure path beyond the size defaulting). pdfEndPattern: True if a capture was open to end; False otherwise (e.g. calling it without a matching pdfBeginPattern, or after already calling pdfEndTemplate/pdfEndPattern once too many times for the current nesting depth).

Remarks. pdfEndPattern and pdfEndTemplate are literally the same function (EndCapture) under two ABI names — either one correctly closes whatever capture (pattern or template) is currently open; the choice of which name to call does not need to match which "begin" call opened it.

See also. pdfCreateStdPattern (a built-in hatch pattern needing no capture at all).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfBeginPattern(IntPtr IPDF, TPatternType PatternType, TTilingType TilingType, double Width, double Height);
Area
Graphics
Category

Core

Exported names

pdfBeginPattern

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.