A 2D <canvas/> rendering context.
The current page index, starting with 0 for the first page.
The size of the page that you're drawing at. The canvas is already scaled accordingly.
Register a RenderPageCallback handler at configuration time.
NutrientViewer.load({
renderPageCallback: function(ctx, pageIndex, pageSize) {
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(pageSize.width, pageSize.height);
ctx.stroke();
ctx.font = "30px Comic Sans MS";
ctx.fillStyle = "red";
ctx.textAlign = "center";
ctx.fillText(
`This is page ${pageIndex + 1}`,
pageSize.width / 2,
pageSize.height / 2
);
}
// ...
});
This callback is called whenever a page is rendered or printed (only for NutrientViewer.PrintMode.DOM). You can use it to render watermarks on the page.
Make sure that the rendering commands are as efficient as possible as they might be invoked multiple times per page (once per tile).
For more information, see Configuration#renderPageCallback.