The first annotation.
The second annotation.
-1 if a renders below b, 1 if a renders above b.
// Render image annotations behind everything else, tiebreak by creation time then id.
instance.setAnnotationRenderingOrderComparator((a, b) => {
const isImageA = a instanceof NutrientViewer.Annotations.ImageAnnotation;
const isImageB = b instanceof NutrientViewer.Annotations.ImageAnnotation;
if (isImageA !== isImageB) return isImageA ? -1 : 1;
if (a.createdAt < b.createdAt) return -1;
if (a.createdAt > b.createdAt) return 1;
return a.id < b.id ? -1 : 1;
});
A comparator function that defines a strict total order for annotation rendering.
Return
-1ifashould render below (behind)b, or1ifashould render above (in front of)b. A strict total order is required — every pair of distinct annotations must have a deterministic ordering.When set via NutrientViewer.Instance#setAnnotationRenderingOrderComparator, this comparator replaces the SDK's default type-based rendering order for non-interactive annotations (e.g. text markups, ink, images, shapes, stamps).
Interactive annotations — widget annotations (form fields), link annotations, and signature annotations — are always rendered above all other annotations regardless of the comparator. This is required to preserve keyboard tab order and accessibility. Use NutrientViewer.Instance#setPageTabOrder to customize the tab order of interactive annotations.
Limitations: