Web SDKv1.0.0

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

ParameterTypeDescription
valueRect | PointA point or rectangle in page space.
pageIndexnumberZero-based page index.

Returns

Rect | Point | null null before the page is laid out, or on a destroyed viewer.

Throws

  • INVALID_ARGUMENT for a page index the document has not, or a value that is neither a Point nor a Rect of 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)`;
}

More in PDFViewer