API referenceRendering & Viewer

rasGetPageMatrix

Nominally: resolve the page-to-device transform matrix for

C
int32_t __stdcall rasGetPageMatrix(IPGC CachePtr, int32_t CursorX, int32_t CursorY, int32_t* DestX, int32_t* DestY, int32_t* Width, int32_t* Height, TCTM* Matrix);
Delphi
function rasGetPageMatrix(CachePtr: IPGC; CursorX, CursorY: Integer; var DestX, DestY, Width, Height: Integer; var Matrix: TCTM): Integer; stdcall;

Purpose. Nominally: resolve the page-to-device transform matrix for whichever page is under a given cursor position.

Description. Ignored parameters: CursorX/CursorY are never read anywhere in the implementation — the function unconditionally computes and returns the matrix for C.CurrPage (the cache's stored current page), not any page located via the cursor position, despite the parameter names strongly implying rasGetPageAt-style hit-testing. Computes DestY by summing every prior page's rendered height plus borders (same accumulation pattern as rasGetPageAt/rasGetPagePos), offsets by the cache's current ScrollX/ScrollY, and fills Matrix as a pure scale+translate (a = d = Zoom, x = DestX, y = DestY, b = c = 0 — no rotation/skew terms are populated even though TCTM supports them).

Parameters.

ParameterDescription
CachePtrTarget page cache.
CursorX, CursorYAccepted but never read — the function always operates on CachePtr's current page, not a cursor-located one.
DestX, DestYOutput: the page's top-left in scrolled viewport coordinates.
Width, HeightOutput: the page's rendered pixel size at current zoom.
MatrixOutput: scale+translate only (a=d=Zoom; rotation/skew always 0).

Return value. The current page number on success; 0 if CachePtr/document/page size doesn't resolve.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int rasGetPageMatrix(IntPtr CachePtr, int CursorX, int CursorY, ref int DestX, ref int DestY, ref int Width, ref int Height, ref TCTM Matrix);
Area
Rendering & Viewer
Category

Rasterizer/Rendering

Exported names

rasGetPageMatrix

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.