Skip to main content
Version: v2023.18.0

Add a highlight notification

The JavaScript API allows you to set up subscriptions to receive events during various actions on ARender (e.g., adding/removing notifications, rotating a page, or clicking on a hyperlink). This information is accessible in the documentation

It is also possible to create highlight-type annotations directly from the host application, without doing so manually in ARender, using the addAnnotation function of the JavaScript API by following these guidelines .

To use this function from an application other than ARender, simply replace the window object in the documentation with the appropriate object based on the framework being used.

const iframeWindow = iframeRef.current.contentWindow;
/*
* Add an highlight annotation
*
* @param {string} documentId - ID of the document
* @param {string} type - the annotation type (only "Highlight" is supported)
* @param {integer} x - the annotation x coordinate
* @param {integer} y - the annotation y coordinate
* @param {integer} w - the annotation width
* @param {integer} h - the annotation height
* @param {page} page - the annotation page
* @param {string} color - the annotation color
* @param {float} opacity - the annotation opacity
*/
var documentId = iframeWindow.getARenderJS().getCurrentDocumentId();
var type = "Highlight";
var x = 50;
var y = 150;
var w = 100;
var h = 50;
var page = 0;
var color = "#FF0000";
var opacity = 0.4;

iframeWindow
.getARenderJS()
.getAnnotationJSAPI()
.addAnnotation(documentId, type, x, y, w, h, page, color, opacity);