Reputation: 357
Is there a way to add a label at the top of sticky note similar to the image below? Other than adding and grouping a text with the sticky note.
if (action == 'add') {
for (const annot of annots) {
if (annot instanceof instance.Core.Annotations.StickyAnnotation) {
const label = new Annotations.FreeTextAnnotation(Annotations.FreeTextAnnotation.Intent.FreeText, {
X: annot.X,
Y: annot.Y - 15,
TextColor: new Annotations.Color(0, 0, 0),
StrokeColor: new Annotations.Color(255, 255, 255, 0),
Width: annot.Width,
Height: 15,
});
label.setContents(annot.Subject);
instance.Core.annotationManager.addAnnotation(label);
instance.Core.annotationManager.redrawAnnotation(label);
instance.Core.annotationManager.groupAnnotations(annot, [annot, label]);
}
}
}
Upvotes: 0
Views: 69
Reputation: 1
This is not a supported feature by the PDF spec by default, however you are using Apryse WebViewer so there are ways to make a similar behaviour.
Step 1: Create your note annotation
Step 2: Create your label as a FreeTextAnnotation: https://docs.apryse.com/documentation/web/guides/annotation/types/FreeTextAnnotation/
Step 3: Group these annotations together via: https://docs.apryse.com/documentation/web/guides/annotation/annotationmanager/grouping#reading-grouped-annotations
Since this is an unsupported behaviour, and is a customized behaviour its not guaranteed to work in other PDF viewers, however if you only view PDFs in WebViewer it should be fine.
Upvotes: 0