PDF.js Express Version
Detailed description of issue
Hi there. This is a follow up question to providing a number at the corner of an annotation using setCustomDrawHandler. StickyAnnotation works well in a sense with the number at the bottom right and it stays there when the note is moved. The issue I am running into is with shapes, specifically Ellipse, Rectangle and Cloud. The number does not start at the bottom right and resizing the shapes does not help either. In addition when I move the annotation the number does not follow. I figured that matching the same width and height as the annotation with the ctx.fillText would work but this is not the case. Appreciate the help!
Expected behaviour
THIS WORKS!
Annotations.setCustomDrawHandler(Annotations.StickyAnnotation, function(
ctx, //canvas context
pageMatrix,
rotation,
options
) {
options.originalDraw(ctx, pageMatrix);
const annot = options.annotation;
const number = 1;
const width = annot.Width;
const height = annot.Height;
const padding = 1;
if (number) {
//circle styles
ctx.fillStyle = '#37A000';
ctx.beginPath();
ctx.arc(width - 6, height - 10, 9, 0, 2 * Math.PI);
ctx.fill();
//number styles
ctx.fillStyle = '#FFFFFF';
ctx.fillText(`${1}`, width - 8, height - 6);
}
});
THIS DOES NOT WORK!
Annotations.setCustomDrawHandler(
Annotations.EllipseAnnotation,
function(
ctx, //canvas context
pageMatrix,
rotation,
options
) {
const annot = options.annotation;
const width = annot.Width;
const height = annot.Height;
const padding = 10;
const number = 1;
if (number) {
//circle styles
ctx.fillStyle = '#37A000';
ctx.beginPath();
ctx.arc(width + padding, height + padding, 9, 0, 2 * Math.PI);
ctx.fill();
//number styles
ctx.fillStyle = '#FFFFFF';
ctx.fillText(`${number}`, width + padding, height + padding);
}
options.originalDraw(ctx, pageMatrix);
}
);
Does your issue happen with every document, or just one?
{Answer here}
Link to document
{Provide a link to the document in question if possible}
Code snippet
{Provide a relevant code snippet}


