PDFViewer.pageToClient()
A point or rectangle of a page, in page space, as it lies in the viewer now: CSS pixels from the container's top-left corner at the current zoom, scroll and rotation (a
Rect comes back with its top-left corner as x, y, as the DOM measures). Convert again after zoomChanged, a scroll or a resize. Page space and the geometry helpers are described under Helpers.methodCoordinatessince 1.0.0
Signature
pageToClient<T extends Rect | Point>(value: T, pageIndex: number): T | null
Parameters
| Parameter | Type | Description |
|---|---|---|
| value | Rect | Point | A point or rectangle in page space. |
| pageIndex | number | Zero-based page index. |
Returns
Rect | Point | null null before the page is laid out, or on a destroyed viewer.
Throws
INVALID_ARGUMENTfor a page index the document has not, or a value that is neither aPointnor aRectof finite numbers.
Example
TypeScript
const [field] = await doc.forms.fields(0); const box = field ? viewer.pageToClient(field.rect, 0) : null; if (box) { badge.style.transform = `translate(${box.x}px, ${box.y}px)`; }